473,394 Members | 1,721 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,394 software developers and data experts.

Multiple Validators against a control

I'm trying to use the ASP.NET validators to check some client-side business
rules. I've got two ASP TextBox controls (call them tbxYear1 and tbxYear2)
used to enter a range of years. I've got a couple things I need to check:

1) tbxYear1 and tbxYear2 are both optional, but if values are entered they
have to integers and non-negative
2) if values are entered for both tbxYear1 and tbxYear2 then tbxYear1 must
be less than tbxYear2

It looks like I can use a couple of the validator controls to, collectively,
make these checks. What I'd like to know is if there is a way to "short
circuit" the comparison sequences that multiple validator controls seem to
go through? For instance, if rule #1 is violated, then it probably doesn't
make sense to warn the user that rule #2 has also been violated.

I'm wondering if a CustomValidator control is the way to go here, but I'm
note sure. I assume this type of scenario happens all the time, so I'm
looking for a best practice.

Thanks!
Nov 19 '05 #1
1 2099
There are some cases where shortcircuiting happens:
1. If the textbox is blank, only the RequiredFieldValidator reports an
error.
2. If the Type property demands Date or a number and the value is not the
format for that type, its disabled.

Once the field has text and matches the type, all validators will report
errors. You are correct that one solution is to rewrite the validator using
a CustomValidator. Another choice is to use a third party validator that can
handle this. I am the author of "Professional Validation And More"
(http://www.peterblum.com/vam/home.aspx). It replaces Microsoft's validators
with 22 greatly improved validators. For example, all of the validators can
have a rule that disables them. For example, you need a RangeValidator and
CompareValidator and both can report an error. In my system, you can assign
have the CompareValidator disable itself if the value is out of range (as
the RangeValidator will be reporting an error). You can also combine the
rules of several validators under one error message using my
MultiConditionValidator.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"epigram" <no****@spammy.com> wrote in message
news:1112722640.c6d135992fd3376400fcd8022f29e6c4@b ubbanews...
I'm trying to use the ASP.NET validators to check some client-side
business rules. I've got two ASP TextBox controls (call them tbxYear1 and
tbxYear2) used to enter a range of years. I've got a couple things I need
to check:

1) tbxYear1 and tbxYear2 are both optional, but if values are entered they
have to integers and non-negative
2) if values are entered for both tbxYear1 and tbxYear2 then tbxYear1 must
be less than tbxYear2

It looks like I can use a couple of the validator controls to,
collectively, make these checks. What I'd like to know is if there is a
way to "short circuit" the comparison sequences that multiple validator
controls seem to go through? For instance, if rule #1 is violated, then
it probably doesn't make sense to warn the user that rule #2 has also been
violated.

I'm wondering if a CustomValidator control is the way to go here, but I'm
note sure. I assume this type of scenario happens all the time, so I'm
looking for a best practice.

Thanks!

Nov 19 '05 #2

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

Similar topics

1
by: Tom Pearson | last post by:
I create controls and validators dynamically dependent on data at runtime. I create the control then the relevant validator(s) for it assigning the Control.ID as the control to validate. These...
0
by: Tom Pearson | last post by:
I create controls and validators dynamically dependent on data at runtime. I create the control then the relevant validator(s) for it assigning the Control.ID as the control to validate. These...
2
by: Avad | last post by:
I have a following screen. The login is a "user control" with validations controls in it. This side I have address book in which "name" is required field. But when I click on "add new user" the...
4
by: Samuel Hon | last post by:
Hi I'm building a custom control which basically takes data from the user and then submits it. I would use the validator controls but if I understand correctly (I've been working with .Net for 2...
6
by: Mark | last post by:
We have Validators embedded in an asp table server control. The table server control is necessary and cannot be replaced. We want to apply CSS formatting to the validators, but the validators...
1
by: Ken Varn | last post by:
If a page has multiple ValidationSummary controls, how does it distinguish which ValidationControls are associated with which ValidationSummary controls? The reason I am asking this is that I...
3
by: rgparkins | last post by:
Hi I am currently having problems with Validators in a user control. I am creating a wizard sign-up process which have the allocated step (hyperlinks" at the top of the page. A user can also...
4
by: Brybot | last post by:
I have a form that i've split up into multiple asp:panels, each panel has a number of validators which work correctly. At on the last panel, i want to commit the data collected to a database. I...
2
by: Jordan S. | last post by:
I'm experimenting with dynamically inserting custom composite Web server controls onto a page. For testing purposes I have two custom composite Web server controls that each have a couple of...
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
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: 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:
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...

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.