Can anyone help me build javscript regular expression to validate 6 digit number with 2 deimal places?
These examples should pass the test
0, 0.0, 0.33, 1, 11, 111, 1111, 11111, 111111
1.33, 1.3, 12.33, 12.3, 123.0, 123.33, 1234.0, 1234.11
tried this:
/^\d{1,4}(\.\d{1,2})?$/
but it fails in jquery when .(dot) is pressed
When you press dot there are no digits after it yet and your regexp fails. So you can try this regexp
/^\d{1,6}(\.\d{0,2})?$/to allow this situation, but be aware that user would be able to enter numbers like this12345.