I have a textbox that accepts up to 7 characters. I need to make sure the value isn’t accepted if it is all zeros before and/or after the decimal place, but i can’t figure out the pattern
e.g 000, 00.000, 0.0000 etc.
cases such as 0.001, 0.1 etc can be allowed
have tried ^[0] but this didnt allow for single zero, or didnt allow for combinations such as 0.001
This regex will accept strings meeting the following conditions:
(?=.*[1-9])\d+(\.\d+)?It will match these strings:
4242.42It will not match these strings:
00.042..42See it in action here.