Validation in ASP.NET
page 5 of 9
by . .
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 31126/ 119

Using Ranges

Ranges

This lets you see if a value is between two ranges. The range (set in MinimumValue and MaximumValue can either be a string or number). This checks to see if a zip code is within a specified range, I also used a Regular Expression Validator to check it too.

Please Enter your Zip Code:<asp:textbox id="ZIP" runat="server" /><p>

<asp:RangeValidator runat="server" ControltoValidate="ZIP" ErrorMessage="Your Zip isn't within the range (8000 - 9000)!" MinimumValue="8000" MaximumValue="9000" />

<asp:RegularExpressionValidator runat="Server" ControltoValidate="ZIP" ErrorMessage="That Zip code is invalid (numbers only and 4 numbers long!)" ValidationExpression="[0-9]{4}|[0-9]{5}" />

The RangeValidator made sure that you kept the value between 8000 and 9000, the regular expression one made sure that it was 4 or 5 (someone would complain if it was only 4) numbers long and only numbers.


View Entire Article

User Comments

Title: Nice   
Name: Nagesh
Date: 2004-07-13 9:49:31 AM
Comment:
Thanks for such quick review ....
Title: GOOD   
Name: NAGESH
Date: 2004-07-13 8:28:00 AM
Comment:
But where is the code!!!!!!!!!!!!!!!!!

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2019 ASPAlliance.com  |  Page Processed at 2019-07-20 2:28:33 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search