views:

28

answers:

3

Hi,

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.

A: 

Isn't normal comparison maxqty > minqty work?

S.Mark
your correct, it work but these we can't do with validation plugin.and i have used that plugin everywhere in website.
Nehal Rupani
A: 

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"},
Reigel
A: 

more details on validation depends on multiple fields

http://docs.jquery.com/Plugins/Validation/multiplefields

joetsuihk