473,386 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

RequiredFieldValidator - one of two fields must be filled?

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
Nov 18 '05 #1
1 2692
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

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Brian Conway | last post by:
I have added in a RequiredFieldValidator to my WebForm, however, when I try to use my date box, before all the other fields are filled out it, it errors out on all the empty fields. I want this...
3
by: Steve Yerkes | last post by:
There seems to be way too much confusion over how to set focus on the a field using a field validator. I looked all over the web and found people trying to do this, but not getting anywhere. There...
7
by: Ed West | last post by:
Hello, I have a simple form with some input boxes. After validation if one fails, then I would like to at the top of the page say something like "The following fields in red are required" and...
4
by: Joe | last post by:
Hello, I have created a login page using dotnet. I am using requiredFieldValidator and noticed that the code works fine in IE but not in Netscape, Opera, Mozilla, Firefox, etc. For example...
5
by: Christian Ista | last post by:
Hello, I have a form with 5 textbox for each one a RequiredFieldValidator I show (*) if the field is missing when I post the form. I'd like when a least one of theses RequiredFieldValidator...
3
by: Nick Goloborodko | last post by:
Hi, I've been having a really weird problem with required field validator. Here's the detailed description of the problem: I have originally been developing my web application on Windows XP...
2
by: Hongbo | last post by:
Hi, I have a Asp.Net written in C#. It serve as information input form. The form encounters sort of random problem with the email field and state field. I have validator attached with these 2...
5
by: bdtmike | last post by:
I'm using VS2005. I have a form that has fields and a required field validator control on it. Everything works great except there's a behavior I'm trying to get working. If a user is on a form...
1
by: staeri | last post by:
In my FormView I have a dropdownlist (dd1) and a textbox (txt1). It's ok to save a record if both are empty or both are filled. If a value is selected in dd1 then txt1 should also be filled to be...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.