I am using ASP.NET Regular Expression Validator to validate a textbox.
Valid Samples:
1
1.1
11.1
11.12
0.1
0.12
Invalid Samples:
0
1.123
As you can see I don’t want the input to contain only 0.
Currently I have this expression which is allowing 0.
^[0-9]{1,2}([/.][0-9]{1,2})?$
What can I do to prevent a single 0?
Any help is much appreciated.
How does this work for you?
Explaination:
(?=.*[1-9])– Matches but excludes anything greater than 1\d+– Matches any digit(\.\d+)?– Matches a decimal point plus the remainder.Ignore the second grouping, this is just to break the regex up.