473,395 Members | 2,467 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,395 software developers and data experts.

validator for 2 fields?

Is there good way to set up a validator on 2 textboxes, so that at
least one of the two has to have something besides blanks? One
approach I thought about was to create a hidden field and use
javascript to update that field from either of the 2 textboxes, and
then set the validator on that one field. However, I don't really
like this approach and would like to see another way of doing it.

If nothing else, will I have to catch this in the codebehind, and if
so, what's the best approach for notifying that user that one of those
2 fields needs to be filled in?

Jul 17 '07 #1
2 1204
Validators are only good for validating one control (unless they've revamped
them in 2.0). If you need a control that governs two then just code it up
yourself.

"HockeyFan" <le**********@gmail.comwrote in message
news:11**********************@i13g2000prf.googlegr oups.com...
Is there good way to set up a validator on 2 textboxes, so that at
least one of the two has to have something besides blanks? One
approach I thought about was to create a hidden field and use
javascript to update that field from either of the 2 textboxes, and
then set the validator on that one field. However, I don't really
like this approach and would like to see another way of doing it.

If nothing else, will I have to catch this in the codebehind, and if
so, what's the best approach for notifying that user that one of those
2 fields needs to be filled in?

Jul 17 '07 #2
Understood. I've coded validations before but was really wanting to know
what other people do when they have to validate to make sure that at least
one of 2 controls contain data. I was wondering if someone had come up with
an elegant solution.

"Aidy" wrote:
Validators are only good for validating one control (unless they've revamped
them in 2.0). If you need a control that governs two then just code it up
yourself.

"HockeyFan" <le**********@gmail.comwrote in message
news:11**********************@i13g2000prf.googlegr oups.com...
Is there good way to set up a validator on 2 textboxes, so that at
least one of the two has to have something besides blanks? One
approach I thought about was to create a hidden field and use
javascript to update that field from either of the 2 textboxes, and
then set the validator on that one field. However, I don't really
like this approach and would like to see another way of doing it.

If nothing else, will I have to catch this in the codebehind, and if
so, what's the best approach for notifying that user that one of those
2 fields needs to be filled in?


Jul 18 '07 #3

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

Similar topics

0
by: Mike Moore | last post by:
We have a min and max qty fields, but we can't seem to get these to work properly. THe min qty is one of requied fields. A user can enter a min of 1 and max could be 0. We would like to...
0
by: TN Bella | last post by:
Hi, I am trying to get my compare validator to fire properly...Since I have panels the validator wouldn't work properly, the app would fire right but would insert the data regardless and the...
9
by: Alex Shirley | last post by:
Hi there I’m simply trying to check for a blank or empty value in a textbox on my webform. In this instance I do not want to use a requiredfieldvalidator, I want to use a customvalidator (as I...
3
by: Angelos Karantzalis | last post by:
Hi guys, I've a small problem with validators. I'm building a single .aspx file that handles all my form posts. I need to be using ASP.NET validators ( or subclasses thereof ), so what i do to...
3
by: Skeptical | last post by:
Hello, I have a form and two buttons on it. Button1 submits the data to a database and RequiredFieldValidator is used to make sure all the required fields are filled up, the second button has a...
6
by: tshad | last post by:
I have about 8 validators on my page and I want to show the error message next to or below the field that has the error, but I also want to put 1 message on the top of the page and one on the...
2
by: Tarun Mistry | last post by:
Hi everyone, is it possible to make a custom validator work on multiple fields? I have 3 input text boxes, I would like a validator that checks to ensure at least 1 of them contains informaion...
0
by: guy | last post by:
I have a simple web form that has 2 password fields, and a compare validator that checks that both are the same - standard stuff. however if nothing is entered in the second password box the...
1
by: Scott Stark | last post by:
I'm using the Microsoft Validator Application Block with attributes to assign validators to various fields in a class. It's pretty straightforward: // public fields used for brevity public...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.