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

How to use validation controls in this scenario ?

Hi everybody
Validation controls are great but i have a scenario where i do not know how
to use them so i am doing my validation on the server.
Let's say I have a Web Form with :
Two Textboxes : Textbox_1, Textbox_2
Two Checkboxes : Checkbox_1, Checkbox_2
A Button : btnSubmit

What I want is :
If Checkbox_1 is checked then Textbox_1 is required and it should contain
Email
If Checkbox_2 is checked then Textbox_2 is required and it should contain
numeric values
If both Checkboxes are checked then both Textboxes are required

If no Checkbox is checked then nothing is required.

I know it should be done using custom validator but cannot make it easily.
At present all my validation code is in the btnSubmit_Click method but that
way i cannot use the advantages of validation controls.

Thanks in advance
Raja


Nov 18 '05 #1
2 1126
Hi Raja:

It appears Peter Blum and myself gave you an answer previously:
http://groups.google.com/groups?hl=e...TNGP11.phx.gbl

--s

On Thu, 22 Jul 2004 22:56:41 +0200, "Ing. Rajesh Kumar"
<iambad(Without This)@post.cz> wrote:
Hi everybody
Validation controls are great but i have a scenario where i do not know how
to use them so i am doing my validation on the server.
Let's say I have a Web Form with :
Two Textboxes : Textbox_1, Textbox_2
Two Checkboxes : Checkbox_1, Checkbox_2
A Button : btnSubmit

What I want is :
If Checkbox_1 is checked then Textbox_1 is required and it should contain
Email
If Checkbox_2 is checked then Textbox_2 is required and it should contain
numeric values
If both Checkboxes are checked then both Textboxes are required

If no Checkbox is checked then nothing is required.

I know it should be done using custom validator but cannot make it easily.
At present all my validation code is in the btnSubmit_Click method but that
way i cannot use the advantages of validation controls.

Thanks in advance
Raja



--
Scott
http://www.OdeToCode.com
Nov 18 '05 #2
Raja,

You could use some javascript to manipulate your
validation controls' enable# attribute in your checkbox
onclick event.

#
I do not have a VS on the computer I am currently on -
please check whether it's enable or enabled on your page
output.

Validation controls skip validation when the control is
not enabled.

Hope this helps.

-----Original Message-----
Hi everybody
Validation controls are great but i have a scenario where i do not know howto use them so i am doing my validation on the server.
Let's say I have a Web Form with :
Two Textboxes : Textbox_1, Textbox_2
Two Checkboxes : Checkbox_1, Checkbox_2
A Button : btnSubmit

What I want is :
If Checkbox_1 is checked then Textbox_1 is required and it should containEmail
If Checkbox_2 is checked then Textbox_2 is required and it should containnumeric values
If both Checkboxes are checked then both Textboxes are required
If no Checkbox is checked then nothing is required.

I know it should be done using custom validator but cannot make it easily.At present all my validation code is in the btnSubmit_Click method but thatway i cannot use the advantages of validation controls.

Thanks in advance
Raja


.

Nov 18 '05 #3

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

Similar topics

3
by: Ben | last post by:
Hi, I have a page with a datagrid that you have to scroll to see. I'm using the StrengthControls SmartScroller as recommended to maintain my scroll position. Anyway, inside the datagrid I have...
3
by: john morales | last post by:
Hi guys, I have a problem and i know there must be a solution for this as it is such a basic common practice in asp.net development. Scenario: i have many webforms in a site, most with two...
2
by: moondaddy | last post by:
How can I have a page with 2 different groups of controls (where each group of controls contain textboxes, validation controls and a submit button) and each group operate independently? for...
0
by: jasondavidcarr | last post by:
Hello all, I have a "comments" page that contains three sections; the article to be commented on is on top, followed by previous comments, and on the bottom a place to add new comments. It's a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.