I am having real trouble with this addMethod for validating a date from an input. It doesn\'t test the regex properly and i think it may be written with errors. The date should
You can create your own custom validation method using the addMethod function. Say you wanted to validate "dd/mm/yyyy":
$.validator.addMethod(
"Mytypedate",
function(value, element) {
// put your own logic here, this is just a (crappy) example
return value.match(/^\d\d?\/\d\d?\/\d\d\d\d$/);
},
"Please enter a date in the format dd/mm/yyyy."
);
And then on your form add:
$('#myForm')
.validate({
rules : {
myDate : {
Mytypedate: true
}
}
})
;