Hello I am using the following regex command to only allow numbers be inputted into a text field
Regex rgx = new Regex("[^0-9]");
however this obviously doesnt allow the inputting of positive and negative signs +/-. I would like to be able to input -9 for a negative value but when i do it comes back as 09 instead. Any help in getting the regular expression right would be appreciated.
There you go, this one works 100% just tested to make sure ;)
Regex r = new Regex("^([-+]?)?[0-9]+(,[0-9]+)?$");
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