Validating multiple fields with one validator?

adam.net

New member
Joined
May 1, 2006
Messages
2
Programming Experience
1-3
I have a bunch of text inputs (First Name, Last Name, Address, Phone Number, etc...) for a user.

On most fields I use the built in RegularExpressionValidator in the toolbox. Then I output the errors to a ValidationSummary (with ShowMessageBox set to true so it pops open a window with all the errors).

This works fine. But one of my inputs is the users Phone number. I have this set up with 3 Text Boxes

1) Area Code text box
2) First 3 digits of phone number text box
3) last 4 digits of phone number.

This is my Regular Expression validations on each
1) [1-9][0-9][0-9] (must be 3 digits with first digit not a 0)
2) [1-9][0-9][0-9] (must be 3 digits with first digit not a 0)
3) \d{4} (must be 4 digits)

Right now if I make an error in all of the 3 phone number fields I will get 3 seperate errors messages in the Message Box but I want to only show one error message if one or more of the phone number fields contain errors (Something like "You entered an incorrect phone number").

Is there away to only output this one error message?
 
Couldn't you put this in an If..Elseif sort of format?
 
Back
Top