I'm trying to create a method for jquery validate plugin to validate if the year entered in a text field is not greater than today's year, but I can't tell why it is not working. Any help is much appreciated.
My script:
$.validator.addMethod("checkYear", function(value, element) {
var year = $("#dateBirthYYYY").val();
var myYear = new Date();
myYear.setFullYear(year);
var currentYear = new Date();
currentYear.getFullYear();
return currentYear > myYear;
}, "Invalid year");
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…