Reputation: 2629
I want to just check the value of two form fields in my jquery validation plugin.
I know I can do it by adding new methods (jQuery.validator.addMethod()), but surely there's a way in my rules declaration to just check the value of these fields?
ie:
rules: {
bothSelected: { value: "0" },
neitherSelected: { value: 0 }
},
I can't seem to find a way to verify the value. I this not possible?
Upvotes: 0
Views: 351
Reputation: 98718
http://jqueryvalidation.org/category/methods/#range-method
range: [0,0]
will require that the field's value be between 0 and 0. It's inclusive, so [0,0]
can only be satisfied by 0
.
rules: {
myFieldName: {
range: [0,0]
}
}
Upvotes: 2