RangeValidator Class
Assembly: System.Web (in system.web.dll)
The RangeValidator control tests whether the value of an input control is within a specified range.
The RangeValidator control uses four key properties to perform its validation. The ControlToValidate property contains the input control to validate. The MinimumValue and MaximumValue properties specify the minimum and maximum values of the valid range.
The BaseCompareValidator.Type property is used to specify the data type of the values to compare. The values to compare are converted to this data type before the validation operation is performed.
Note: |
|---|
| When the Type property is set to Date and the current calendar type is non-Gregorian, the validator performs server-side validation only. The validator client script supports only Gregorian calendars. |
The following table lists the different data types that can be compared.
| Data Type | Description |
|---|---|
| String | A string data type. |
| Integer | A 32-bit signed integer data type. |
| Double | A double-precision floating point number data type. |
| Date | A date data type. |
| Currency | A decimal data type that can contain currency symbols. |
Note: |
|---|
| Validation succeeds if the input control is empty. Use a RequiredFieldValidator control to make the input control a mandatory field. |
Note: |
|---|
| The RangeValidator control throws an exception if the value specified by the MaximumValue or MinimumValue property cannot be converted to the specified BaseCompareValidator.Type. |
For additional information on validation controls, see BaseValidator.
Accessibility
The markup rendered by default for this control might not conform to accessibility standards such as the Web Content Accessibility Guidelines 1.0 (WCAG) priority 1 guidelines. For details about accessibility support for this control, see ASP.NET Controls and Accessibility.
The following example demonstrates how to create a RangeValidator control on the Web page to determine whether the value entered into an input control is within the comparison range.
Security Note: |
|---|
| This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview (Visual Studio). |
Note:
Security Note: