I am after a regex that will match numeric values with up to a user defined number of decimal places. Currently I have
/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/
which will allow as many places as input but I would also like to sometimes allow 2 for currency or 4 or more for other input. The function I am building is
var isNumeric = function(val, decimals) {
// decimals is not used yet
var objRegExp = /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
return objRegExp.test(val);
};