开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜