How can I specify a custom date formate to be validated with the Validation Plugin for jQuery?
You can create your own custom validation method using the addMethod
function. Say you wanted to validate "dd/mm/yyyy":
$.validator.addMethod(
"australianDate",
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 : {
australianDate : true
}
}
})
;