问题
I want to validate an input ( date of birth ) using jQuery Validation plugin, but it must be in format "dd/mm/yyyy" and also not validate when the date of year is over 2002.
So the date is valid when it's in this format "dd/mm/yyyy" and year over "2002"
回答1:
I find the answer :D this is it. Thanks all
$.validator.addMethod("birth", function (value, element) {
var year = value.split('/');
if ( value.match(/^\d\d?\/\d\d?\/\d\d\d\d$/) && parseInt(year[2]) <= 2002 )
return true;
else
return false;
});
来源:https://stackoverflow.com/questions/10982386/jquery-how-to-validate-a-date-of-birth-using-jquery-validation-plugin