Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do i block past dates in coldfusion flash form

Posted on 2009-03-31
6
Medium Priority
?
186 Views
Last Modified: 2013-12-24
i have two fields for date in my form (start Date and End date). when the user selects a start date, i want them to choose a date between today and future, not a date that has already passed. i have seen that on expedia.com, i think there might be some JS or action scripts ned to be integrated, but not sure how. any idea will be helpful.
<cfparam name="start_date" default="">
<cfparam name="end_date" default=""> 
 
	<cfform format="Flash" skin="haloOrange" height="340" width="780" action="components/actions.cfc?method=insertData">
			
		
	  		<cfformgroup type="panel" label="ENTER DATE">
	  	 		<cfinput type="dateField" name="start_date" label="Start Date" width="100" value="#start_date#" required="true">
	  	 		<cfinput type="dateField" name="end_date" label="End Date" width="100" value="#end_date#" required="true">
				<cfinput type="hidden" name="type" value="d" >
			</cfformgroup>
			
		
			<cfformgroup type="horizontal" style="horizontalAlign:center">
				<cfinput type="Submit" name="save" value="Save" width="100">
				<cfinput type="Submit" name="apply" value="Submit" width="100">   
			</cfformgroup>
		</cfformgroup> 
	</cfform>

Open in new window

0
Comment
Question by:khan02
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 24032045
Try this tip:
http://www.justskins.com/forums/setting-datefield-selectablerange-5882.html
<cfparam name="start_date" default="">
<cfparam name="end_date" default=""> 
 
<cfform name="yourForm" format="Flash" skin="haloOrange" height="340" width="780" onLoad="runOnLoad();" action="components/actions.cfc?method=insertData" >
	<cfoutput>
	<cfformitem type="script">
		function runOnLoad() 
		{
			var strDate:String = "#dateFormat(now(), 'yyyy-m-d')#";
			var parts:Array = strDate.split("-");
			var y = parts[0];			 
			var m = parts[1];			 
			var d = parts[2];
			// Month numbers are 0-11 (January to December)
			var startAfter:Date = new Date(y, m-1, d);
			start_date.selectableRange={rangeStart: startAfter};	
		}
	</cfformitem>
	</cfoutput>
	<cfformgroup type="panel" label="ENTER DATE">
    	<cfinput type="dateField" name="start_date" label="Start Date" width="100" value="#start_date#" required="true">
		<cfinput type="dateField" name="end_date" label="End Date" width="100" value="#end_date#" required="true">
		<cfinput type="hidden" name="startAfterDate" value="#dateFormat(now(), 'yyyy-m-d')#">
        <cfinput type="hidden" name="type" value="d" >
	</cfformgroup>
                        
                
    <cfformgroup type="horizontal" style="horizontalAlign:center">
    	<cfinput type="Submit" name="save" value="Save" width="100">
        <cfinput type="Submit" name="apply" value="Submit" width="100">   
    </cfformgroup>
</cfform>

Open in new window

0
 

Author Comment

by:khan02
ID: 24051646
this looks good but, there are some problems. it is not allowing me to pick a date from past month which is fine, but it also should not let me pick a past date of current month. so, today is april 2nd, but it does allow me to pick date as april 1st, which supposed to be block me to pick april 1st.

also, when i click to next button to pick a day from next month (month May), then the calender doesn't let me allow to come back current month (April). can these be fixed.... or at least it shouldn't allow me to choose past day (i'e April 1st)...
0
 
LVL 52

Expert Comment

by:_agx_
ID: 24051715
Are you using the exact example posted above, or did you modify it?  Because it works perfectly for me (ie April 1st is disabled and after selecting a different month, it does allow navigation back to previous months)
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:khan02
ID: 24051848
i copied and pasted your example and i got the following error,

 Illegal usage of actionscript org.apache.oro.text.regex.Perl5Pattern@3cc532.
The following actionscript commands are not allowed: "import, new, delete, createChild, loadmovie, duplicateMovieClip, AttachMovie, registerclass, createTextField, __proto__, uiobjectdescriptor, createclassobject, createemptyobject, createchildatdepth, createchildren, createclasschildatdepth, createobject, createchild, webservice, httpservice, remoteobject".
 

Then i took of 'new' from the script on line >>var startAfter:Date = new Date(y, m-1, d); and replaced with var startAfter:Date =  Date(y, m-1, d);

and the form started loading.

i don't know if there is any issue with my coldfusion verion, cause i am using
ColdFusion Server Developer        7,0,2,142559
Template       /CFD/dates.cfm
Time Stamp       02-Apr-09 11:38 AM
Locale       English (US)
User Agent       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8 (.NET CLR 3.5.30729)
Remote IP       127.0.0.1
Host Name       localhost
 
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 2000 total points
ID: 24051966
Yes, it was tested with CF8, so it might be a version problem.  What happens if you use try this code for runOnLoad(..) instead?


        <cfoutput>
        <cfformitem type="script">
                function runOnLoad() 
                {
                        var dateString = "#dateFormat(now(), 'yyyy-mm-dd')#";
                        var startAfter = mx.formatters.DateFormatter.parseDateString(dateString);
                        start_date.selectableRange={rangeStart: startAfter};    
                }
        </cfformitem>
        </cfoutput>

Open in new window

0
 

Author Comment

by:khan02
ID: 24052067
perfect ....that works !!!!!!!!!!!! yahooooooo.....grate ....!!!

is there any tutorials or good links that you can provide, that i can learn action scripting and apply in my CF applications.
0

Featured Post

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question