From jquery.validate.js, this regex is used to validate a number. The problem is that it fails on .33 and passes on 0.33. I need to make it pass with, or without, the leading 0.
^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$
Try this
^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$
The extra question mark (spot it!) will make all the part before the decimal point optional.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With