JSFiddle - React, Tailwind, and code Playground
by UI Designer
HTML
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js"></script>
<form id="test">min:
<input id="min" name="min" type="text" class="txt"
/>Max:
<input id="max" name="max" type="text" class="txt"
/>
</form>
JavaScript
$.validator.addMethod("greater", function (value, element, param) {
var $otherElement = $(param);
return parseInt(value, 10) > parseInt($otherElement.val(), 10);
}, "Max must be greater other field");
$('#test').validate({
rules: {
min: {
required: false,
min: 0,
number: true
},
max: {
required: true,
min: 1,
number: true,
greater: "#min"
}
}
});