RangeValidator control

The RangeValidator control checks that a user's entry is between specified lower and upper boundaries. You can check ranges within pairs of numbers, alphabetic characters, and dates.

A RangeValidator works in conjunction with another control, for example a TextBox control. Add the control you want to validate to your page before you add the RangeValidator so that you can easily associate the RangeValidator with it.

To add a RangeValidator control to a page

  1. Drag the RangeValidator control from the Toolbox task pane to your page.

  2. Select the RangeValidator in Design view, right-click it, and click Properties on the shortcut menu.

  3. In the Tag Properties task pane, select the control you want to validate with the RangeValidator in the ControlToValidate property dropdown.

  4. Set the MaximumValue and MinimumValue properties to the highest and lowest values, respectively, that you want to allow a user to enter into the control you are validating.

  5. If you are going to use a ValidationSummary control to consolidate validation error messages, set the ValidationGroup property to the name of the group of validation controls. This can be any string, as long as all the controls in the group have the same value.

  6. For a full description of all RangeValidator control properties, see RangeValidator Members in the MSDN library.

  7. For more information about using validation controls to validate user input, see How-to Topics — Validation Controls in the MSDN library.

See also


ASP.NET validation controls overview

CompareValidator control

CustomValidator control

RegularExpressionValidator control

RequiredFieldValidator control

ValidationSummary control