I would like to allow user to type the following decimal or integer values (A)
.5
0.500
3
0
0.0
30
500000
4000.22
0.
This is the following regex that I have used:
factor: /^-?\d*[.]??\d*$/,
But the problem is that the above regex also allow the following invalid number (B)
. (comment: a single dot )
00.5 (multiple zeros before dot)
0000.5
00 (multiple zeros)
Also not allow user type negative values i.e. -3, -0.5
I am trying to modify the above regex to not allow the invalid values at (B), but allows the values at (A)
My attempt which does not work:
factor: /^-?\d*[.]+\d*$/,