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
- Add a RequiredFieldValidator control to the form that contains the target control.
- Use the drop-down list next to the ControlToValidate property in the Properties window to select the ID of the control to validate.
- 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.
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