Sometimes you need to validate your ASP.net web form user input for numeric values.. The following works for me
Any integer, positive or negative
^[-+]?[0-9]*$
Validates
-9
9
12
1352345234
–3434134
+34
Does not validate
-9.6
+89.9
Any decimal/float value
Being: positive or negative, specified maximum length, limited number of decimals
^[-+]?\d{0,12}(\.\d{1,2})?$
Validates
123456789012.34
-123456789012.34
+123.45
D0es not validate
1234567890123
1234.123
Comments
Post a Comment