Reputation: 3302
I am using jquery validation. I need an input field to be number and Denominations of $250 only. The code i have for validation is
rules: {
myPrice: {
required: true,
number: true
}
Now I need it be only denominations of $250. ???
Upvotes: 0
Views: 778
Reputation: 23801
You need to add a new custom method to check if your price is in denomination of 250,hence simply add a new method using $.validator.addMethod
$.validator.addMethod('denominationCheck', function (value) {
return Number(value) % 250 == 0;
}, '');
And in your rules modify as below
rules: {
myPrice: {
required: true,
number: true,
denominationCheck : 0
}
Hope this helps
Upvotes: 3