Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Adding and Configuring 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 when the control being validated fails the test.
    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

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

Show:
© 2015 Microsoft