Im using the jQuery validate plugin and was wondering if there was a way to validate if the date entered into a field was a date like yyyy-mm-dd AND the the date falls betwe
I've never used the validation plugin, but a look through the API suggests that something like this might work:
$.validator.addMethod('daterange', function(value, element) {
if (this.optional(element)) {
return true;
}
var startDate = Date.parse('2010-11-29'),
endDate = Date.parse('2010-12-15'),
enteredDate = Date.parse(value);
if (isNan(enteredDate)) {
return false;
}
return ((startDate <= enteredDate) && (enteredDate <= endDate));
});
You would then, I think, need to add the daterange
class the the appropriate element.