I have a form with two date fields, start_date
and end_date
. I want to create a rule that end_date
must be greater then start_date
, and if this condition returns false
then to show validation errors as in the picture below.
So far I've tried to do so by creating a custom rule:
$.validator.addMethod("check_date", function(value, element) {
var start_date = $("input[name='start_date']").val();
var end_date = $("input[name='end_date']").val();
return end_date(value) > start_date(value);
}, 'End date must be greater then start date.');
I'm not sure how exactly I set the rule and the message.