I need Help for currency regex in jQuery function.
Here is the regular expression that should achieve this for you.
The start must be numeric or $ sign. There can be any number of digits with commas, but it must start and end with a digit. There can optionally be a decimal point with up to two digits after it at the end of the line.
var your_input = "$1,000,000.00";
var valid_dollar_amt_regex = /^\$?[0-9][0-9,]*[0-9]\.?[0-9]{0,2}$/i;
if(valid_dollar_amt_regex.test(your_input))
alert("Valid!");
Or use this function
function validate_money(i) {
var valid_dollar_amt_regex = /^\$?[0-9][0-9,]*[0-9]\.?[0-9]{0,2}$/i;
return valid_dollar_amt_regex.test(i);
}
See it working: http://jsfiddle.net/znuJf/