My date validation regex is not working correctly ...
validates_format_of :dob, :with => /\d{2}\/\d{2}\/\d{4}/, :message => "^Date must be in the following format: mm/dd/yyyy"
What am I missing here? I am trying to verify that the date has the following format: mm / dd / yyyy. When I enter something that should be reliable, I still get an error message.
Thanks for the help. Here is a snippet of code from my form that passes the dob value to:
<tr>
<td>
<%= f.label :dob, "Date of Birth: " %>
</td>
<td>
<%= calendar_date_select_tag "user[dob]", "", :format => :american, :year_range => 50.years.ago..0.years.ago %>
</td>
</tr>
I think this may have something to do with my use of this js calendar plugin. A related problem is that my dob value is not supported in the field, if the message does not pass the validation - the previously entered date value is cleared ...
Thanks!
Tom
source
share