I need to alter users input and leave in the box only integer or decimal values, i.e. 4567 or 354.5635. I use the following statement:
v = v.replace(/[^\d\.]+/g, "");
But this allows multiple decimal points such as 345.45.345.67. How do I ensure that only one point is there?
I’d recommend to use
parseFloathere:This will guarantee you to have integer/decimal value or
NaN.