Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Format Validation 1

Status
Not open for further replies.

ecobb

Programmer
Dec 5, 2002
2,190
US
I have a form in which users enter a date in the form of mm/dd/yy. But I've noticed that sometimes a user (one particular user!) enters the date in the form of mm/ddyy, so CF and SQL Server get 8/1403, which returns an error.

I've tried validating it with "IsDate" and several different variations of IF statements such as:

<cfif Form.Date NEQ #DateFormat(Form.Date, 'mm/dd/yy')#>
Error
<cfelse>
No Error
</cfif>


But CF always seems to let this date get through, which of course bombs out when it hits the SQL Server.

Is there any way that I can validate that the date format is mm/dd/yy?

Thanks!

 
<cfif ListLen(form.date,&quot;/&quot;) EQ 3 AND IsDate(form.date)>
No Error
<cfelse>
Error
</cfif>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top