Date validation does not work?

Posted on 2006-03-23
Last Modified: 2013-12-24
I have two forms that manipulate a SQL Server database. One form creates/adds new records and the other updates the records. Each form has validation for the date fields. The form that creates/adds a new record works well and will give a message before submitting if the dates are entered in the wrong format. the code sample is:

<cfinput type="text" name="AssmApproveDate" message="Date must be mm/dd/yy format" validate="date" pattern="mm/dd/yy" value="" size="8" maxlength="8" tabindex="4">

The update form has the date values populated from the database. If no date changes are made the submit will work fine but if a wrong date format is entered or a date changed to a wrong format the validation does not work and the form is submitted resulting in a CF error for the stored procedure on the processing page that states that a the value can not be added to the DateTime field. Here is a code sample on this form:

<cfinput type="text" name="AssmApproveDate" message="Assembly Approval Date must be mm/dd/yy format" validate="date" pattern="mm/dd/yy" size="8" maxlength="8" tabindex="4" value='#DateFormat(Select_record.AssmApproveDate, "m/d/yy")#'>

Any ideas why the validate will not work on this second page?
Question by:apwbe
    LVL 10

    Accepted Solution

    I think there may be some confusion with the validation going on.

    You have both a pattern attribute and a validate attribute.  You actually only need one of these and not both.
    "pattern" needs a valid regular expression.  Unfortunately, "mm/dd/yy" is not valid regex, or at least not for what you actually want to happen.
    "validate" of type "date" used clientside will match "a US date of the format mm/dd/yy mm-dd-yy or mm.dd.yy, with 1-2 digit days and months, 1-4 digit years." (from the Adobe/Macromedia livedocs)

    Try removing the pattern attribute from the cfinput on both forms.

    Also, you probably should use the same format as you're expecting when you put the date from the database into the cfinput value.  At the moment you have #DateFormat(Select_record.AssmApproveDate, "m/d/yy")#  when really you should have #DateFormat(Select_record.AssmApproveDate, "mm/dd/yy")#

    Hope that helps.

    Author Comment

    Mr Nil,

    Thank you for you quick response to this question. I new it would be something simple but really needed a solution fast as i was under the gun.

    Godd luck and thanks again!


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Suggested Solutions

    A web service ( is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
    Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now