• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 424
  • Last Modified:

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?
0
apwbe
Asked:
apwbe
1 Solution
 
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
 
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now