By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,307 Members | 2,071 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,307 IT Pros & Developers. It's quick & easy.

Required Field Validation question

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.