473,471 Members | 1,684 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

validating only a part of the form


hi
I m facing the following problem often :
In a web page the user can click on 2 buttons "button1" and "button2".
If the user clicked on button1 then I have to validate part of the form
(some controls musn't be validated), and if the user clicked on button2
then I have to validate the other part of the form.
Usually I would do this by using one custom validator (for all the web
page) that detects the button that has been clicked and perform
validation. In this way, I m writting the validation using javascript
code. I managed to do this before however now I m facing more and more
complicated validations, so I was wondering if there's a way to disable
some validators according to the button that has been clicked.

Regards

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #1
4 1179
Hi

Sounds to me like your design is wrong :-) Can't you have two different
forms instead of one form with two purposes?

Instead of using validators you could validate the form using code in
the button, I have written an article about adding errors at runtime here...

http://www.howtodothings.com/ViewArt...px?Article=660
--
Pete
====
ECO Modeler, Audio compression components, DIB graphics controls,
FastStrings
http://www.droopyeyes.com

Read or write articles on just about anything
http://www.HowToDoThings.com

My blog
http://blogs.slcdug.org/petermorris/
Nov 19 '05 #2
In ASP.NET 1.x Validation is page-wide. One thing you can do is to set one
of the Button's CausesValidation property to false.

In ASP.NET 2.0 they have the ability to have ValidationGroups which allows
different regions of validation on a single page.

-Brock
DevelopMentor
http://staff.develop.com/ballen
hi
I m facing the following problem often :
In a web page the user can click on 2 buttons "button1" and "button2".
If the user clicked on button1 then I have to validate part of the
form
(some controls musn't be validated), and if the user clicked on
button2
then I have to validate the other part of the form.
Usually I would do this by using one custom validator (for all the web
page) that detects the button that has been clicked and perform
validation. In this way, I m writting the validation using javascript
code. I managed to do this before however now I m facing more and more
complicated validations, so I was wondering if there's a way to
disable
some validators according to the button that has been clicked.
Regards

*** Sent via Developersdex http://www.developersdex.com *** Don't just
participate in USENET...get rewarded for it!


Nov 19 '05 #3
Not yet, but is ASP.NET 2.0, they have added validation groups that buttons
will only validate certain input fields, for now you will need to come up
with a solution on your own. You could always cheat and only have server
side validation.

What I do, or rather used to do, is decide the most complicated validation
button, set the validation for that button and input controls. I will
manually check the smaller validation set manually solely in code behind and
set CausesValidation to false for the "easy" button.

bill
"Joe Abou Jaoude" <an*******@devdex.com> wrote in message
news:Oc*************@TK2MSFTNGP15.phx.gbl...

hi
I m facing the following problem often :
In a web page the user can click on 2 buttons "button1" and "button2".
If the user clicked on button1 then I have to validate part of the form
(some controls musn't be validated), and if the user clicked on button2
then I have to validate the other part of the form.
Usually I would do this by using one custom validator (for all the web
page) that detects the button that has been clicked and perform
validation. In this way, I m writting the validation using javascript
code. I managed to do this before however now I m facing more and more
complicated validations, so I was wondering if there's a way to disable
some validators according to the button that has been clicked.

Regards

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #4
Hi Joe,

Validation groups are available in third party replacements to the ASP.NET
validators.
I created "Professional Validation And More"
(http://www.peterblum.com/vam/home.aspx) to address a large list of
limitations and missing features in validation. Each of my 22 validators
supports "validation groups" and my client-side validation works on far more
browsers than the original validators do. My validators also have the
ability to smartly enable themselves based on setttings on the page, like if
a checkbox is checked, then the validator is enabled. You will find
extensive improvements on how validators and the ValidationSummary control
communicate with the user, like changing the color of the field with the
error and offering a hyperlink on each error message in the
ValidationSummary to jump to the field with the error.

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

"Joe Abou Jaoude" <an*******@devdex.com> wrote in message
news:Oc*************@TK2MSFTNGP15.phx.gbl...

hi
I m facing the following problem often :
In a web page the user can click on 2 buttons "button1" and "button2".
If the user clicked on button1 then I have to validate part of the form
(some controls musn't be validated), and if the user clicked on button2
then I have to validate the other part of the form.
Usually I would do this by using one custom validator (for all the web
page) that detects the button that has been clicked and perform
validation. In this way, I m writting the validation using javascript
code. I managed to do this before however now I m facing more and more
complicated validations, so I was wondering if there's a way to disable
some validators according to the button that has been clicked.

Regards

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #5

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

Similar topics

5
by: The Plankmeister | last post by:
Hi... What's the best method of validating input characters? I would like to prevent users submitting exotic characters (such as those acquired on Windows Systems by pressing ALT+) and thought...
3
by: Mark | last post by:
Hi, Im trying to validate a form, all the validating works apart from one field. This particular field must consist of the first 2 characters as letters, & the following 5 as numbers. And if it...
2
by: Chris Dunaway | last post by:
I have a form with a textbox and numerous panels, buttons and other controls. I have handled the textbox Validating and Validated events. The textbox will hold a filename. In the validating...
0
by: Matthew | last post by:
All, I have searched google and the newsgroups but can't find anything the same as what I am experiencing (though I may have missed something). I have controls (textboxes) within UserControls...
0
by: Gary Shell | last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852...
7
by: Bruce HS | last post by:
I'd like to call my ancestor Validation Function every time any control on a Win Form generates a Validating or Validated event. I'm using VB. I've extended Textbox, for instance, to have its...
21
by: Darin | last post by:
I have a form w/ a textbox and Cancel button on it. I have a routine to handle textbox.validating, and I have the form setup so the Cancel button is the Cancel button. WHen the user clicks on...
4
by: easoftware | last post by:
I am using VS .Net 2003 and VB. I have an app with one parent and two Mdi child forms. I need to validate data in the Mdi form. The Form.Validating event works when I try to close a Mdi form,...
16
by: Al Santino | last post by:
Hi, It appears displaying a messagebox in a validating event will cancel the subsequent event. In the program below, button 2's click event doesn't fire if you open a dialog box in button 1's...
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
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
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
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...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
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.