I am using jQuery validation plugin 'jquery.validation.js' to validate date data type in 'date_of_birth' field
I want to display a custom message above the "date_of_birth" filed as 'Age should be minimum of 16' .
So I have written the following customised validation code :
{literal}
jQuery.validator.addMethod("dob", function (value, element) {
var startDate = $('#date_of_birth').val();
var finDate = 01/03/2012
var age=Date.parse(finDate)-Date.parse(startDate);
if (age >= 16){
return false;
}
else
{
return true;
}
}, "Age should be minimum of 16");
{/literal}
custom validation rules:
rules: {
date_of_birth: {
dob: true
}
}
But the sad part is that it's not working.
Please help me out...
Thanks in advance.