I want to validate max quanity is greater then min qty in validation js
I want to validate whether one element is greater then second one using validation plugin of jquery. There is no direct method available for doing this. There is one method called 开发者_如何学编程equalTo: but it's not doing stuff.
maybe you need something like what is in this link
something like:
$.validator.addMethod('greaterThan', function(value, element, param) { return ( IsNaN( value ) && IsNaN( $(param).val() ) ) || ( value > $(param).val() ); }, 'Must be greater than {0}.' );
$.validator.addMethod('lesserThan', function(value, element, param) { return ( IsNaN( value ) && IsNaN( $(param).val() ) ) || ( value < $(param).val() ); }, 'Must be lesser than {0}.' );
you can use this like:
number1: {required:true, greaterThan: "#number2"},
anothernum1: {required:true, lesserThan: "#anothernum2"},
more details on validation depends on multiple fields
http://docs.jquery.com/Plugins/Validation/multiplefields
精彩评论