How to: Add and Configure a RangeValidator ControlĀ
Use the RangeValidator control to check that the value of another control falls within a range that you specify.
Note |
---|
If the user leaves the targeted control blank, the control passes the range validation. To force the user to enter a value, add a RequiredFieldValidator control as well. |
To validate the value of a control against a range of values
Add a RangeValidator control to the form that contains the target control.
Set the control's ControlToValidate property to the ID of the control that you want to validate.
Select the type of the data being validated from one of the types in the drop-down list next to the Type property.
Note If the value in the targeted control is not valid according to the Type property, the validation fails.
Set the low and high values of the range with the MinimumValue and MaximumValue properties, respectively.
Enter text for the ErrorMessage property. The RangeValidator control displays this text when the control being validated fails the test.
Note If you enter text into the Text property, the RangeValidator control displays that text when an error occurs. If the Text property is left empty, the RangeValidator control displays the string in the ErrorMessage property.
See Also
Tasks
How to: Add and Configure a CompareValidator Control
How to: Add and Configure a CustomValidator Control
How to: Add and Configure a RegularExpressionValidator Control
How to: Add and Configure a RequiredFieldValidator Control
How to: Add and Configure a ValidationSummary Control