Export (0) Print
Expand All

Adding and Configuring a RangeValidator Control

Use the RangeValidator control to validate 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

  1. Add a RangeValidator control to the form that contains the target control.
  2. Use the drop-down list next to the ControlToValidate property in the Properties window to select the ID of the control that you want to validate.
  3. 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.
  4. Set the low and high values of the range with the MinimumValue and MaximumValue properties, respectively.
  5. Type a text string into the ErrorMessage property in the Properties window. The RangeValidator control displays this text when the control being validated fails the test.
    Note   If you enter a string 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

Introduction to the Validation Controls | Adding and Configuring a CompareValidator Control | Adding and Configuring a CustomValidator Control | Adding and Configuring a RegularExpressionValidator Control | Adding and Configuring a RequiredFieldValidator Control | Adding and Configuring a ValidationSummary Control

Show:
© 2014 Microsoft