ASP.NET validators don't do this automatically. The RequiredFieldValidator
only looks at a single textbox at a time.
I can offer two solutions:
1. Use the CustomValidator and write the logic yourself. On the server side,
its pretty easy. On the client-side, you have to know a bit about javascript
and DHTML.
2. I wrote a replacement to the ASP.NET validators that can easily handle
this. Professional Validation And More
(
http://www.peterblum.com/vam/home.aspx) includes 22 validators that work on
many more browsers. One validator is the MultiConditionValidator. Use it to
combine other validators and build AND/OR logic expressions. In your case,
you need two required validators combined with an OR statement: TextBox1 is
required or TextBox2 is required.
Even if you don't want a commercial solution, it helps to know the
limitations of ASP.NET validators so you can better plan your project. I put
together a list that I've found at
http://www.peterblum.com/vam/valmain.aspx.
--- Peter Blum
www.PeterBlum.com
Email:
PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
"Dan Nash" <da*@musoswire.co.uk> wrote in message
news:6A**********************************@microsof t.com...
Hi guys
Is there a way to get a Validator to work so that the user must enter text
in either one of 2 boxes? I want people to have to enter either a Contact
Name or a Company.
Any help appreciated.
Cheers
Dan