RequiredfieldValidator
Below we have a textbox control ‘email’ that will retrieve the user’s email address and a RequiredFieldValidator. The RequiredFieldValidator’s ControlToValidate property is set to the id of the textbox control. This associates the validator with the input control and ensures that a value must be entered otherwise the Text property will display it's message.
RegularExpressionValidator
Be aware in the example above that as long as the user enters a value then a validation error won’t be raised. The problem with that is the user could still enter an incorrectly formatted email address. The RegularExpressionValidator ensures that the value entered follows a specified pattern or format.
The example below ensures that a value is entered using the RequiredFieldValidator and that a specified pattern is followed using the RegularExpressionValidator. Both controls have their ControlToValidate properties set to the id of the textbox email.
The RequiredFieldValidator and RegularExpressionValidator partner-up ensuring an email is entered and a properly formatted one at that.
If you are using Visual Web Developer you can select from a range of regular expressions that are already provided.
If you select the validation control in the VWD designer, and then look in the properties window you can select the elispsis next to the ValidationExpression property.

You can then select from a list of common regular expression functions as the screenshots below demonstrate.

Read Part 3 Validation Control Properties |
Read Part 5 The CompareValidator Control |
Get the best asp hosting provider from web-hosting-top.com and save up to 30%
Plug and play ASP membership script that integrates with PayPal to let you charge recurring membership fees.
