hi i am using jquery validation plugin , i want to add a validation to my price field ,
the only available are numbers 0-9 , comma , dot
1000
1000.00
1,000.00
should be available please help . this is my function
var x=$("#form").validate({
rules: {
price: {
custom_number: true
}
},
messages: {
}
});
$.validator.addMethod("custom_number", function(value, element) {
return this.optional(element) || value === "NA" ||
value.match(/^[0-9,\+-]+$/);
}, "Please enter a valid number");
i want to add my expression here value.match(/^[0-9,\+-]+$/)
thanks………………………….
Here is the RegExp that should work:
Here you can test it against various strings.