473,748 Members | 7,608 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1528
Set "CausesValidati on" to false on your button.

Then do something like this
Page.Validators .Remove(ThatVal idator 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 CausesValidatio n=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. "Profession al 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****@PeterBlu m.com
Creator of "Profession al Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Peter Morris [Air Software Ltd]" <pe**********@g uess.co.uk> wrote in
message news:%2******** **********@TK2M SFTNGP12.phx.gb l...
Set "CausesValidati on" to false on your button.

Then do something like this
Page.Validators .Remove(ThatVal idator 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.in fo> wrote in message
news:%2******** ********@TK2MSF TNGP10.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 CausesValidatio n=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. "Profession al 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****@PeterBlu m.com
Creator of "Profession al Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Peter Morris [Air Software Ltd]" <pe**********@g uess.co.uk> wrote in
message news:%2******** **********@TK2M SFTNGP12.phx.gb l...
Set "CausesValidati on" to false on your button.

Then do something like this
Page.Validators .Remove(ThatVal idator 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
2104
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 null. By I have set the default value of () to null. I can't set the "required" value of the field to yes as it isn't required all the time and haven't been successful trying to set a validation rule. Any help would be much appreciated,
3
2786
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 field is not filled out. However in Netscape NONE of the required field validations occurs at all in Netscape. The form is posting correctly because I can walk through the post back process. Any ideas why this is happening or how to fix it?
5
2421
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 description blank and I do get the error messages. But the code still continues to run the addfolder method from my class. Is there something wrong with this?
1
1636
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 email field for help but not both. Thanks for any help. --Ken
6
21321
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 validation? Thanks -- Paul G Software engineer.
6
2287
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" HeaderText="Password"> <ItemTemplate> <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Password") %>' ID="lblPassword"></asp:Label> </ItemTemplate> <EditItemTemplate>
7
2049
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. In IE, the validation works, but no form ever gets submited. It doesn't even process the click event of the button. In mozilla, it works 100% (this is weird because it's usually the oposite). Any thoughts?
2
2352
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 takes the values of the text boxes & puts them into an SQL database. After adding the required field validator, when I click any button, (be it submit button ot link button or any other button), it shows the required field validator's TEXT i.e...
3
2715
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 the user enters some text into a field called "txbName" and when they click on the submit button, if they have not entered anything into the field, a Required Field Validator will say "Invalid Name". Thanks,
1
1935
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 The field 'table1.firstname' cannot contain a null valve because the required property for the field is set to True. Enter a value in this field Regards,
0
8989
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8828
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9537
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9243
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.