Validating Decimal Numbers
jquery, jquery-validate
Solution
You can use the number validation method found here
From the docs:
$("#myform").validate({
rules: {
field: {
required: true,
number: true
}
}
});
In your case:
rules: {
paid_amount: {
required:true,
number: true
}
},
messages: {
paid_amount: {
required: "Enter Paid Amount",
number: "Decimal Numbers Only"
}
}
Problem
I have a form and I am using jQuery validation plugin to validate it. Now I am trying to validate decimal number input. I have tried the following code, but its not working. Is the problem with the regular expression or the way of writing the custom rule is wrong in my code? ``` rules: { paid_amount: { required:true, rexp: ^[1-9]\d*(\.\d+)?$ }, } }, messages: { paid_amount: { required: "Enter Paid Amount", rexp:"Decimal Numbers Only" }, } }); ```