Click here to Skip to main content
15,888,255 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to use a regular expression validator for a textbox in my website

The textbox must only accept number ranging from 5-20 and must be number with no any letters and others

please help me out to sort this out

thanks
Posted

Instead of using Regular Expression, I would suggest the following validation:
  1. Compare the length of the input string with 5 and 20, check up if it's in the valid range. (You may want to trim the string before doing it.)
  2. Check if this a valid number:
    VB
    Dim input As String = ' ...
    Dim value As ULong
    If ULong.TryParse(input, value) Then
        ' input is valid, and value is a valid number
    End If


Why? Because one of your validation steps will also give you the numeric value for free; it's very like that you will need it. :-)

—SA
 
Share this answer
 
Comments
Patrice T 5-Jan-16 20:23pm    
+5
Sergey Alexandrovich Kryukov 5-Jan-16 21:40pm    
Thank you.
Happy New Year!
—SA
Checkout below regular expression, and check if it resolved
'\b1[5-20]\b'
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900