Using regular expression text box should accept 1 or 2 or 3 or 4 or 5 Max digits numbers only restrict decimal part
I need to validate the text box at server side by using regular exp which should accept 1 or 2 or 3 or 4 or 5 digits numbers 开发者_运维技巧.Need to restrict decimal part.
Ex: 1 or 23 or 455 or 5643 or 45667 --Should accept.
1.3, .2, 33.3 , 444.55 ,5555.99 -- should not accept.
Thanks in advance
You could also use two CompareValidators. One to validate if the user has entered an integer an one that validates if the value is less than 100000.
To make a CompareValidator check for integers, set Operator="DataTypeCheck"
and Type="Integer"
. To check if it is less than 100000 set Operator="LessThan"
and ValueToCompare="100000"
.
Try This:
^[0]$|^[1-9][\d]{0,4}$
OR
^[0]$|^[1-9][0-9]{0,4}$
Hope this helps...
Your regex should look like @"^\d{1,5}$"
精彩评论