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

tie validator to a specific submit button ?

To use a simple example, if I have a web form with two textboxes
Textbox1 and Textbox2, two Required Field Validators Validator1 (which
validates Textbox1) and Validator2 (for Textbox2), and two buttons
Button1 and Button2, can I specify that Validator1 should only
validate if Button1 is pressed, and Validator2 should only validate if
Button2 is pressed? If Button2 is pressed, we do not need Textbox1,
and if Button1 is pressed we do not need Textbox2. Note this is a
simlified example, it would not be possible to just have Textbox1 and
two buttons - in actuality there are many textboxes, each with
validators for data type and range as well as required fields, and
many buttons. I just want to know if this kind of thing is possible or
what is done in such a case. Currently validation is done in the
codebehind. Thanks.
Nov 18 '05 #1
2 1588
Change then to Custom Validators controlled serverside then disable/enable
them with the click events and call the Page.Validate

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Mad Scientist Jr" <us*************@yahoo.com> wrote in message
news:7a**************************@posting.google.c om...
To use a simple example, if I have a web form with two textboxes
Textbox1 and Textbox2, two Required Field Validators Validator1 (which
validates Textbox1) and Validator2 (for Textbox2), and two buttons
Button1 and Button2, can I specify that Validator1 should only
validate if Button1 is pressed, and Validator2 should only validate if
Button2 is pressed? If Button2 is pressed, we do not need Textbox1,
and if Button1 is pressed we do not need Textbox2. Note this is a
simlified example, it would not be possible to just have Textbox1 and
two buttons - in actuality there are many textboxes, each with
validators for data type and range as well as required fields, and
many buttons. I just want to know if this kind of thing is possible or
what is done in such a case. Currently validation is done in the
codebehind. Thanks.

Nov 18 '05 #2
It sounds like you need the feature called "validation groups" which is
coming in ASP.NET 2.0 (due in Spring of 2005 and available today in Beta 1
from Microsoft). This allows you to assign a group name to each button and
the validators it fires.

Without it, you have to use a different strategy that abandons client-side
validation. Someone recommended a customvalidator. I
recommend in the Click event for each button, call the Validate() method on
individual validators that are involved. Then test each validator's own
IsValid property and continue if all are true.

I offer a commercial solution for this problem that provides validation
groups and works fully on the client side: "Professional Validation And
More" (http://www.peterblum.com/vam/home.aspx).

There are many limitations in Microsoft's validator controls. I've put
together a list of them at http://www.peterblum.com/vam/valmain.aspx to help
people plan their validation designs.

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

"Mad Scientist Jr" <us*************@yahoo.com> wrote in message
news:7a**************************@posting.google.c om...
To use a simple example, if I have a web form with two textboxes
Textbox1 and Textbox2, two Required Field Validators Validator1 (which
validates Textbox1) and Validator2 (for Textbox2), and two buttons
Button1 and Button2, can I specify that Validator1 should only
validate if Button1 is pressed, and Validator2 should only validate if
Button2 is pressed? If Button2 is pressed, we do not need Textbox1,
and if Button1 is pressed we do not need Textbox2. Note this is a
simlified example, it would not be possible to just have Textbox1 and
two buttons - in actuality there are many textboxes, each with
validators for data type and range as well as required fields, and
many buttons. I just want to know if this kind of thing is possible or
what is done in such a case. Currently validation is done in the
codebehind. Thanks.

Nov 18 '05 #3

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

Similar topics

3
by: Matt | last post by:
I want to understand the difference between submit button and regular button: <input type="submit"> and <input type="button">. My understanding is that submit button will send the entire HTML form...
1
by: reneecccwest | last post by:
Hello, I'd like to pass the "levelbtn" value when I click the filter button, but there are also other submit form buttons. I defined as "document.testform.submit();" in the javascript, but I...
2
by: Matt | last post by:
In the following code, I have 2 questions regarding submit button with image. 1) Does this code <input type="image" name="populate" src="populate.gif"> behave the same as an HTML submit button...
4
by: Frank Way | last post by:
Hi all, I've googled this one to death, and still can't find an answer. Not sure I'm asking the right question, but here goes: Have a form with an onSubmit that has some javscript to disable...
2
by: Pawel | last post by:
Hello All I have a submit button in my form. It gets focus (is activated by ENTER) everytime any text inputs are edited. So, if the user press ENTER before finishing all form, the form is...
4
by: Dmitry Korolyov [MVP] | last post by:
When we use btnSubmit.Attributes = "javascript: this.disabled=true;" to make the button disabled and prevent users from clicking it again while form data still posting, there is no longer...
3
by: Jeff | last post by:
I have a payment form with a submit button. A large percentage of users double-click the submit button thus submitting their payment information twice. I would like to use javascript to disable...
2
by: Martin Knott | last post by:
Hopefully an easy answer. I've got a form with 1 input field, and a submit button. I register an event for the button, run in debug mode, push the button and sure enough I'm in the event...
4
by: adria | last post by:
Is it possible to create a script that calls a different submit button class for a specific submit button in a form, whereas the rest of the buttons are another class? These are the two button...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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
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,...
0
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...

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.