There's a function IsDate()  that will go some of the way - make sure
people can't enter 31/Feb for example,  but it still doesn't solve the
problem of people putting dates early in the month the wrong way round
(e.g. 5 July as 7/5).   It returns a boolean true or false such as:

<cfif IsDate(createdate("#form.year#","#form.month#","#form.day#"))>
      Stuff here if it's a valid date
<cfelse>
      Stuff here if it's not a valid date
</cfif>


So I'm with Tom McLean - I like to use drop down menus to select the
day/month/year, usually with a default set to the most likely choice
(i.e. today if the app calls for that) or else a javascript or flash
date picker,  and then validate the date with the IsDate() function to
ensure they've chosen a real date.  That accounts for leap years as
well.

Cheers
Mike Kear
Windsor, NSW, Australia
Certified Advanced ColdFusion Developer
AFP Webworks
http://afpwebworks.com
ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month
 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> Sent: Tuesday, 15 February 2005 4:38 PM
> To: CFAussie Mailing List
> Subject: [cfaussie] validating dates and passing them to the database
> 
> Got some problems with dates...
> 
> I have a form that is requesting dates in the format dd/mm/yyyy.  I want
> to do the following:
> 
> 1. I want to validate server side that they are enterring a valid date
> in the format above 2. I want to make sure that when inserted into the
> database that the months and days don't get swapped around
> 
> Any help would be great.
> 
> Thanks Jason.
>

---
You are currently subscribed to cfaussie as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to