Share via


How to: Add and Configure a RequiredFieldValidator Control

Use the RequiredFieldValidator control to validate that the data entry field in a TextBox or SelectionList control is not empty.

Note

Required-entry validation is frequently used in conjunction with other types of validation controls. You can use as many validation controls for a user-entry field as necessary.

To validate a required entry

  1. Add a RequiredFieldValidator 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 to validate.

  3. Type a text string into the ErrorMessage property in the Properties window. The RequiredFieldValidator control displays this text if the user does not enter a value.

    Note

    If you enter a string into the Text property, the RequiredFieldValidator control displays that text when an error occurs. If the Text property is left empty, the RequiredFieldValidator control displays the string in the ErrorMessage property.

See Also

Tasks

How to: Add and Configure a CustomValidator Control

How to: Add and Configure a RangeValidator Control

How to: Add and Configure a RegularExpressionValidator Control

How to: Add and Configure a RequiredFieldValidator Control

Concepts

Introduction to the RequiredFieldValidator Control

Introduction to the Validation Controls