I see this problem all of the time.
The ASP.NET validators do not handle this behavior automatically. Instead,
you have to use the CustomValidator and write the logic in your own
evaluation function. The trickiest part is writing the client-side function,
when you don't know DHTML and JavaScript. Many users have not done this part
and live with a server side only validator.
I built a replacement to Microsoft's validators that handles this.
"Professional Validation And More" (
http://www.peterblum.com/vam/home.aspx)
includes 22 validators. Its MultiConditionValidator is designed for this. It
lets you merge the logic of other validators together into a boolean
expression like "TextBox1 is Required OR TextBox2 is Required". It generates
the javascript for you. All javascript runs on IE, IE/Mac,
Netscape/Mozilla/FireFox, Opera 7 and Safari whereas Microsoft's only
handles the IE browsers.
--- Peter Blum
www.PeterBlum.com
Email:
PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
"Darrel" <no*****@nospam.com> wrote in message
news:uV**************@TK2MSFTNGP11.phx.gbl...
(whew...I'm full of questions tonight!)
I have two textBoxes that I need to validate. One's a phone number and
one's an email address. I need to only validate one of them, though. (ie,
only email or only phone are required).
How can I do this? I've set up a custom control the checks both of these
fields and if they're both blank, it returns a 'one of the two must be
filled in' error.
I think I'd like to do something like this:
if textbox.text > "" then validate with regex validator
but I'm not sure how to go about that.