I am trying to write a "Less than" validator for jQuery. I want to compare one text box against another, so if I have:
<input type="text" id="value1" /> <input type="text" id="value2" />
I want my validator to look like
$('#myForm').validate({rules: { value1: { lessThan: "#value2" } } });
I have tried this but I can't get it to work:
$.validator.addMethod('lessThan', function(value, element, param) {
var i = parseInt(value);
var j = parseInt($(param).val());
return i >= j;
}, "Less Than");
Another question is where should I put that code? In $(document).ready or just in a tag?