How to: Add and Configure a CustomValidator Control
If the user leaves the targeted control blank, it passes the custom validation test. To force the user to enter a value, add a RequiredFieldValidator control as well. For details, see How to: Add and Configure a RequiredFieldValidator Control.
To validate with a CustomValidator control
Add a CustomValidator control to the form that contains the target control.
Set the ControlToValidate property to the ID of the control to validate.
Set the ErrorMessage property to a string to display if the target control fails validation.
Switch to Design view, and then double-click the CustomValidator control.
Visual Studio opens the code editor with an empty validation method.
Create the handler. For details, see Introduction to the CustomValidator Control.