You can use the ASP.NET 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.
Set the low and high values of the range using the and properties.
Set the property to specify the data type of the range settings. Use the enumeration, which enables you to specify the following types:
If the user leaves a control blank, the control passes the range validation. To force the user to enter a value, add a 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.