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

Required Field Validation question

Can you make a required field validator optional? I know it sounds crazy,
but....

Let's say I have a signup form. It consists of 2 sections. The top section
is a "GOLD MEMBER" section. It has required validators for name, address,
etc... The next section is the "BRONZE MEMBER" section. It also has
required validators for the same fields. The user only has to fill out 1
set of info.

Any thoughts on how to accomplish this?

Thanks!
Nov 19 '05 #1
3 1507
Set "CausesValidation" to false on your button.

Then do something like this
Page.Validators.Remove(ThatValidator as IValidator)

Then call Page.Validate() before checking Page.IsValid
--
Pete
====
Read or write articles on just about anything
http://www.HowToDoThings.com

My blog
http://blogs.slcdug.org/petermorris/
Nov 19 '05 #2
Oh boy, sorry Pete but that solution isn't going to do it. If you want to
disable a validator on the server side, just set its Enabled property to
false. Don't remove it from Page.Validators. (Really!)

VB Programmer, it is *VERY* common to desire a validator that is disabled
based on other values on the page. It's too bad that Microsoft's validators
don't have this capability. You have several choices:
1. Write a custom validator that applies your rules. This is only a good
direction if you intend to keep client-side validation (because of #2
below). So you will have to figure out the javascript and DHTML logic in
your custom validator.
2. Abandon client-side validation. Do this:
- Set CausesValidation=false
- In your Click event method, call the Validate() method on individual
validators that apply.
3. Switch your validation system to something that actually handles this
case. "Professional Validation And More"
(http://www.peterblum.com/vam/home.aspx) is a replacement to Microsoft's
validators. All of its 22 validators support the following features and
provide client-side validation on many more browsers than IE and IE/Mac
which Microsoft supports:
- Use the Enabler property on a validator to setup a rule that determines if
the validator should fire. For example, the rule can test if a textbox has
text. That textbox can be in the GOLD MEMBER section. The validator is in
the BRONZE MEMBER section.
- Use "validation groups". Have separate Submit buttons for each group of
fields. The button and validators all have a property called "Group". Assign
the same name to the button and its validators in the Group property. The
button will only validate those in its group.

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

"Peter Morris [Air Software Ltd]" <pe**********@guess.co.uk> wrote in
message news:%2******************@TK2MSFTNGP12.phx.gbl...
Set "CausesValidation" to false on your button.

Then do something like this
Page.Validators.Remove(ThatValidator as IValidator)

Then call Page.Validate() before checking Page.IsValid
--
Pete
====
Read or write articles on just about anything
http://www.HowToDoThings.com

My blog
http://blogs.slcdug.org/petermorris/

Nov 19 '05 #3
Thanks for all the advice guys!!!!

"Peter Blum" <PL****@Blum.info> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Oh boy, sorry Pete but that solution isn't going to do it. If you want to
disable a validator on the server side, just set its Enabled property to
false. Don't remove it from Page.Validators. (Really!)

VB Programmer, it is *VERY* common to desire a validator that is disabled
based on other values on the page. It's too bad that Microsoft's
validators don't have this capability. You have several choices:
1. Write a custom validator that applies your rules. This is only a good
direction if you intend to keep client-side validation (because of #2
below). So you will have to figure out the javascript and DHTML logic in
your custom validator.
2. Abandon client-side validation. Do this:
- Set CausesValidation=false
- In your Click event method, call the Validate() method on individual
validators that apply.
3. Switch your validation system to something that actually handles this
case. "Professional Validation And More"
(http://www.peterblum.com/vam/home.aspx) is a replacement to Microsoft's
validators. All of its 22 validators support the following features and
provide client-side validation on many more browsers than IE and IE/Mac
which Microsoft supports:
- Use the Enabler property on a validator to setup a rule that determines
if the validator should fire. For example, the rule can test if a textbox
has text. That textbox can be in the GOLD MEMBER section. The validator is
in the BRONZE MEMBER section.
- Use "validation groups". Have separate Submit buttons for each group of
fields. The button and validators all have a property called "Group".
Assign the same name to the button and its validators in the Group
property. The button will only validate those in its group.

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

"Peter Morris [Air Software Ltd]" <pe**********@guess.co.uk> wrote in
message news:%2******************@TK2MSFTNGP12.phx.gbl...
Set "CausesValidation" to false on your button.

Then do something like this
Page.Validators.Remove(ThatValidator as IValidator)

Then call Page.Validate() before checking Page.IsValid
--
Pete
====
Read or write articles on just about anything
http://www.HowToDoThings.com

My blog
http://blogs.slcdug.org/petermorris/


Nov 19 '05 #4

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

Similar topics

2
by: Mark Reed | last post by:
Hi all, This is probably a really simple question but I have been unable to figure it out. I have a field () which needs to have a value entered by the user but only if another field () is not...
3
by: Rick | last post by:
I have an interesting problem when I run the following code in Netscape (7.02) vs. IE. This page works great in IE and all my controls bring up the validation summary dialog box if the required...
5
by: Do | last post by:
Hi, Has anybody run into problems with Page.IsValid? My errors show up when the fields aren't filled correctly, but my processing continues even if the page is invalid. I leave name and...
1
by: Kenneth Baltrinic | last post by:
Is there an easy way with a validation control to have either one field or another required but not both? This is for a forgotten password page where the user must fill in either a user ID or...
6
by: Paul | last post by:
I am trying to setup a field validator and tried using the control to validate set to a dropdown list box but did not seem to work. Is there anyway to set this up or do you need to use client side...
6
by: hansiman | last post by:
I'm having trouble getting the required field validator to work. I can still save the row in the datagrid... I can't see what I'm doing wrong. <asp:TemplateColumn SortExpression="c.Password"...
7
by: Ryan Ternier | last post by:
We're running a site that has required field validation on the login page. It works fine on our development / test machines. However, when I upload this site to our live server i get this error. ...
2
by: pmud | last post by:
Hi, I have an ASP.Net web page . The page was working fine until I added a required field field validator. My page has a link button which takes the user to another page, a submit button which...
3
by: Kivak Wolf | last post by:
Hi, Could someone give me a quick review of how to use the required field Validator? I'm completely at a loss, and MSDN does not help one bit. =/ Basically all I want done is to make sure that...
1
by: Denis | last post by:
Hi I have a field called firstname in a table called table1. I have it set as required in a form. How do I display a customized error message rather than the standard one given by Access below ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.