I'm using the jQuery Validate plugin and wanted to know how can I validate that a given date is in the current year?
I have this code that make sure the field is required and that it is a valid date, but I want to also make sure the date is in the current year, current being 2017
// orders dates fields are required and must be in current year
$(".order-dates").each(function (item) {
$(this).rules("add", {
required: true,
date: true
});
});
.each()at all I think..rulesshould operate over a collection - since it's a plugin. It's absolutely strangeitemis left secret from us..."I want to also make sure the date is in the current year, current being 2017"... what date?.each()is absolutely required here since this plugin's methods can only be attached to a single element, not a collection.