Date validation does not work?

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?
apwbeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mr_NilCommented:
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.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
apwbeAuthor Commented:
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!

Warren
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.