Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking a Textbox for a Numveric value 1

Status
Not open for further replies.

dashen

Programmer
Jul 14, 2005
233
US
Hi I was wondering if any of you have had any experience with validating a textbox for a numeric value "0"-"99"

I tried IsNumeric(CInt(textbox.text)) but that only throws an error when it is not. Even IsNumeric(textbox.text) throws an exception.

I was wondering if there was any validationcontrol or even something programmatically that you may know of. I set the textbox to posttback/autovalidate. Any ideas? Thanks.
 
You can use the RangeValidator control to accomplish this:

Code:
<asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="textbox" MinimumValue="0" MaximumValue="99" ErrorMessage="RangeValidator"></asp:RangeValidator>
 
Will this take care of Required field validation too?
 
Will this take care of Required field validation too?
No, you will need a separate RequiredFieldValidator. As for your orginal question, you can use a RegEx validation or a compare validator and set the datatype.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top