I'm trying to use a custom validation rule with jquery.validator. In the form there are 2 text fields 'startdate' and 'enddate', containing date strings (using jquery.ui datepicker). The date in the 'enddate' field has to be "bigger than" the one in startdate.
I found the following 'greaterThan' custom function in the additional file that comes with validator:
$.validator.addMethod( "greaterThan", function( value, element, param ) {
var target = $( param );
if ( this.settings.onfocusout && target.not( ".validate-greaterThan-blur" ).length ) {
target.addClass( "validate-greaterThan-blur" ).on( "blur.validate-greaterThan", function() {
$( element ).valid();
} );
}
return value > target.val();
}, "Please enter a greater value." );
Now I'm not sure how to do write the 'rules' part for this field. Thanks for help!! Regards
I tried something like this:
rules {
enddate:{
greaterThan: true,
value: startdate
}
}
but that doesn't work...