
Validating for Multiple Conditions
Generally, each validation control performs only one test. If you want to check for multiple conditions, you can attach more than one validation control to the TextBox or SelectionList control. In that case, the validation tests are resolved using a logical AND — the data entered by the user must pass all the tests to be considered valid.
In instances where a logical OR operation is required, use the RegularExpressionValidator control. For example, if you are prompting for a phone number, you might allow users to enter a local number, a long-distance number, or an international number. To perform this type of test, use a pattern in the RegularExpressionValidator control.
Note: |
|---|
Applications cannot use multiple validation controls to perform a logical OR operation. Multiple validations on a
TextBox or SelectionList control are always performed with a logical AND.
|
Some of the validation controls test for a valid data type as part of their test. This enables you to combine a test for a data type with a test for a range or specific value into a single validation control. For example, the RangeValidator control can test whether the information that the user entered is a date, and can test that the date falls within a specific range.