0

I have a form with some "as-you-go" validation in place, it is working great for my email input and zip code, but I have no idea how to validate for a specific format for the Date of Birth field (dob).

Any ideas?

<script>
$(document).ready(function(){

  $("#inquiry-fantasy").validate({
   errorContainer: ".messageBox",
   errorLabelContainer: ".messageBox ul",
   wrapper: "li",
});

$("#zip").rules("add", {
 digits: true,
 minlength: 5,
 maxlength: 5,
 messages: { digits: "Please enter a 5 digit zipcode", minlength: "Please enter a 5 digit zipcode", maxlength: "Please enter a 5 digit zipcode"}
});

$("#email").rules("add", {
 required: true,
 minlength: 5,
 messages: { required: "Please Enter your Email Address"}
});

$("#dob").rules("add", {
 digits: true,
 messages: { digits: "Please enter your date of birth in MM/DD/YYYY format"}
});

});
</script>
user3389286
  • 33
  • 2
  • 4
  • 1
    Assuming you're using [this](http://jqueryvalidation.org) try `date: true` http://jqueryvalidation.org/date-method/ – Daniel Jun 09 '14 at 15:36
  • Ah, yes... thank you so much. Is there a way to make sure month is up to 12, day up to 31 and year is 4 digits? – user3389286 Jun 09 '14 at 15:49
  • user regex validation and provide the regex for your scenario as mentioned here http://stackoverflow.com/questions/280759/jquery-validate-how-to-add-a-rule-for-regular-expression-validation – Sherin Mathew Jun 10 '14 at 04:29

0 Answers0