We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


date validation in coldfusion 7

khan02 asked
Medium Priority
Last Modified: 2013-12-24
hi, i have tow dates, Start date and end date. if user selects start date as 07/01/09 and end date as 07/08/09, then it's valid. but right now my code doesn't validate if user enters start date as 07/15/09 and end date as 07/10/09. end date must have to be a future date (or grater then start Date). how can i validate this in coldfusion. all i need a server side validation. see the action script below, which enables user to select date from today to future. the script is fine, but i need server side validation for user, so that an end date must have to be grater then start date. please provide some code or references.
			<cfformitem type="script">
	                function runOnLoad() 
	                        var dateString = "#dateFormat(now(), 'yyyy-mm-dd')#";
	                        var startAfter = mx.formatters.DateFormatter.parseDateString(dateString);
	                        start_date.selectableRange={rangeStart: startAfter};    
							end_date.selectableRange={rangeStart: startAfter}; 

Open in new window

Watch Question

Most Valuable Expert 2015

Do you mean CF code (server) or cfform actionscript (client)?

For server side, you can use the DateCompare() function to determine if the startDate is _greater_ than the endDate.

<!--- should also validate values are valid date strings --->
<cfset form.startDate = "07/15/2009" >
<cfset form.endDate = "07/10/2009">

<!--- if startDate is GREATER than endDate --->
<cfif dateCompare(form.startDate, form.endDate) eq 1>
      StartDate cannot be greater than EndDate
       Okay. StartDate is less than or equal to EndDate


i am so grateful that you have replied so quick, i just realized that, i do need client side validation as well.

the above code you send is for server side validation. can you provide me code for client side validation as well.


thank you once again.
Most Valuable Expert 2015
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview


grate solution...thank you very much
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.