DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   ASP.NET (http://www.daniweb.com/forums/forum18.html)
-   -   Regular Expressions (http://www.daniweb.com/forums/thread125353.html)

menelaussa May 21st, 2008 6:47 am
Regular Expressions
 
Hi, can someone to help me to write an regular expression for a number from 1-100.
I need to validate an age field.

Thank you

nandhinijp May 21st, 2008 7:37 am
Re: Regular Expressions
 
You can use RangeValidator for your requirement.Try this!

<asp:RangeValidator ID="validateage" runat="server" Type="Integer" ControlToValidate="txtage" MinimumValue="1" 
        MaximumValue="100" ErrorMessage="Your age must be between 1 and 100" Display="Dynamic" ></asp:RangeValidator>

menelaussa May 21st, 2008 7:41 am
Re: Regular Expressions
 
I found it
^[1-9][0-9]?[0-9]?$

menelaussa May 21st, 2008 7:44 am
Re: Regular Expressions
 
Thank you nandhinijp. Your solutin is better then mine.

nandhinijp May 21st, 2008 7:52 am
Re: Regular Expressions
 
If its ok, Mark as Solved.


All times are GMT -4. The time now is 10:52 pm.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC