How to: Validate Against a Range of Values for ASP.NET Server Controls
You can use the ASP.NET RangeValidator control to determine whether a user's entry falls within a specific range of values—for example, between two numbers, between two dates, or between alphabetic characters. You set the upper and lower bounds of the range as properties of a RangeValidator control. You must also specify the data type of the values that the control will validate. If the user's entry cannot be converted to the specified data type—for example, it cannot be converted to a date—the validation fails.
To validate against a range of values
Add a RangeValidator control to the page and set the following properties:
The ID of the control for which the user must provide a value.
Properties that specify the text and location of the error or errors that will appear if the user skips the control. For details, see How to: Control Validation Error Message Display for ASP.NET Server Controls.
If the user leaves a control blank, the control passes the range validation. To force the user to enter a value, add a RequiredFieldValidator control as well. For details, see How to: Validate Required Entries for ASP.NET Server Controls.
Add a test in your ASP.NET Web page code to check for validity. For details, see How to: Test Validity Programmatically for ASP.NET Server Controls.