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

Please help. Validate only selected controls

Hi,

I hope somebody can help me with the following. (I have tried
searching for a solution on the newsgroups but nothing is quite what I
need. Feel free to point me in the direction of anything I may have
missed though.)

I have a form with 2 text boxes, two list boxes and 2 buttons (A & B).
Both buttons must perform some validation but they differ in their
extent. Button A must ensure that a date has been entered in both text
fields and that at least one item has been selected in one of the list
boxes (it is always the same one). Button B however must ensure that a
date has been entered in both text fields and that at least one item
has been selected in each list box. Button A serves to populate the
other list box based on the values in the text boxes and the selected
item in the list box. Button B serves to submit the form when it is
totally complete.

I have added the necessary validation controls (i.e. combination of
RequiredFieldValidators, RangeValidators and CompareValidators) to my
form so that all fields are validated when Button B is clicked. What
can I do so that if Button A is clicked that only the text boxes and
one list box is validated. The EnableClientScript property of each
validation control is true so the form is validated client side and
this is something I'd like to maintain. I'm using a validation summary
control to display error messages.

Any help would be appreciated.

TIA

Paul
Nov 18 '05 #1
2 1613
This sounds like a case where you need ASP.NET 2.0's "Validation Groups".
You would define unique names for each group of validators that you want to
fire. Assign those names to the Groupname property on validators and the
buttons. Yet, ASP.NET 2.0 will not be shipping for a while. Don't give up
hope though. Validation Groups is available in commercial validation
products. Mine is "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx.

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

"Paul" <pa********@hotmail.com> wrote in message
news:ca**************************@posting.google.c om...
Hi,

I hope somebody can help me with the following. (I have tried
searching for a solution on the newsgroups but nothing is quite what I
need. Feel free to point me in the direction of anything I may have
missed though.)

I have a form with 2 text boxes, two list boxes and 2 buttons (A & B).
Both buttons must perform some validation but they differ in their
extent. Button A must ensure that a date has been entered in both text
fields and that at least one item has been selected in one of the list
boxes (it is always the same one). Button B however must ensure that a
date has been entered in both text fields and that at least one item
has been selected in each list box. Button A serves to populate the
other list box based on the values in the text boxes and the selected
item in the list box. Button B serves to submit the form when it is
totally complete.

I have added the necessary validation controls (i.e. combination of
RequiredFieldValidators, RangeValidators and CompareValidators) to my
form so that all fields are validated when Button B is clicked. What
can I do so that if Button A is clicked that only the text boxes and
one list box is validated. The EnableClientScript property of each
validation control is true so the form is validated client side and
this is something I'd like to maintain. I'm using a validation summary
control to display error messages.

Any help would be appreciated.

TIA

Paul

Nov 18 '05 #2
Hi Peter,

I look forward to being able to use validation groups when we upgrade
to ASP 2.0.

I did get around this in the end by setting the CausesValidation
property of Button A to false then adding javascript that would get
executed on its click event

ButtonA.Attributes.Add("onClick", "return validateForm();")

The javascript would only validate certain controls. It used many of
the functions and objects present in the mini-API that you can use on
the client, for example ValidatorValidate, ValidatorEnable,
Page_IsValid, Page_Validators etc.

On the server side I just disabled certain validation controls before
calling the page validate method.
Nov 18 '05 #3

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

Similar topics

6
by: francisco lopez | last post by:
ok , first of all sorry if my english is not so good, I do my best. here is my problem: I donīt know much javascript so I wrote a very simple one to validate a form I have on my webpage. ...
3
by: cdj | last post by:
Hi all, I've got a tabControl, initially with one tabPage, along with two buttons, one to add another tabPage, and one to delete the current (selected) tabPage. On each tabPage, when it is...
7
by: Stephen | last post by:
I have some code which I call from a custom validator however I seem to have got the logic wrong and im having trouble figuring out how to write my code to get things to work the way I require....
1
by: Paul | last post by:
Hi, I'm developing a search facility for my web app. In order for the search criteria to be valid the user must (a) enter some text in a text box and check and least one checkbox (of which there...
4
by: Pacific Design Studios | last post by:
I have a DataGrid on Form1 that displays a small amount of information about employees. On Form2 I want to have all the data displaying in text boxes about the employee selected in the datagrid on...
1
by: Kum | last post by:
Hi, I need help in asp.net dynamic textbox controls validation. I am creating textbox controls dynamically on a asp.net webpage. Now after creating the textboxes on the page I want to validate...
1
by: sab | last post by:
Hi, We have a web form with a listbox. The listbox is a multiple select listbox and has data that looks something like: ALL Unit 1 Unit 2 Unit 3 Note: "ALL" is always the first item in...
2
by: J-P-W | last post by:
Hi I'm a VB bloke really, but need to use javascript from time to time. I have a form an validate it as follows: ~~~~~~~~~~ function Validate() { if (QuotePart2.SubsidenceCover.Value=="Yes"...
3
by: Robert Dufour | last post by:
I am trying to localize a very simple web site (english and french) I have a master page and one content page for now. On the master page I have placed a Localize control On the content page I...
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: 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
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?
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
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...
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...

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.