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

required validation based on value selected from dropdown list

parshupooja
159 100+
Hello,

I am using asp.net C#
I have a form which has various controls such as Dropdownlist, textboxes.
If user select value"10" or "13' from drop down than textbox field should become mandatory, otherwise it can be left blank.

Any help will be appreciated
Thank You
Aug 20 '07 #1
5 5231
nateraaaa
663 Expert 512MB
Hello,

I am using asp.net C#
I have a form which has various controls such as Dropdownlist, textboxes.
If user select value"10" or "13' from drop down than textbox field should become mandatory, otherwise it can be left blank.

Any help will be appreciated
Thank You
When you say it becomes mandatory do you mean that the form cannot be submitted until data is entered in the textbox?
Aug 20 '07 #2
parshupooja
159 100+
Yes it should become mandatory and if not filled in , form can not be submitted

Thank You
Aug 20 '07 #3
Plater
7,872 Expert 4TB
That sounds like a javascript enfocement thing.
If those conditions come up, you should have javascript telling people that the form can't be sumbited until something is filled into that textbox, if they try and submit it with it blank
Aug 20 '07 #4
parshupooja
159 100+
Hi

I am not good in Javascript. If you think I should use Javascript than can you please show me?


Thank You
Aug 20 '07 #5
nateraaaa
663 Expert 512MB
Hi

I am not good in Javascript. If you think I should use Javascript than can you please show me?


Thank You
Javascript would be the easiest but you can also do this in the code behind. Create a boolean variable that will determine if the form can be submitted. Now create an if statement that will tell you if 10 or 13 are selected in the dropdownlist. If they are set your boolean to false. Finally write an if statement that will check the boolean and determine whether or not to proceed with the submit. Here is a quick sample of the code:

bool submit = true;

if(dropdownlist1.SelectedValue == 10 || dropdownlist1.SelectedValue == 13)
{
submit = false;
}

if(submit == false)
{
Label1.Text = "You must enter text in the textbox";
//you could also use a javascript popup window here to inform the user.
}
else
{
//submit the form with an insert proc or something.
}

Nathan
Aug 20 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Stephen | last post by:
Could someone please help me with some validation. I have to write code which checks to see whether a dropdown list is populated with a value or a checkbox is checked. I want the code to run on the...
0
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....
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....
6
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...
3
by: msnews.microsoft.com | last post by:
Hi All, I m facing problem in Server Side Validation. For Example The Scenario is I have two fields on the page 1 Country Dropdown List 2 Province Textbox 3 State Dropdown List
3
by: Mike Collins | last post by:
Is it possible to use a required field validator and have it make a user answer a comment field based on a drop down value picked? For instance, if the user selects "It was terrible", make them...
5
by: =?Utf-8?B?bWNhdWxpZmZl?= | last post by:
I have an old application ( pre-VB5) that I need to add a select/option list to. This is an edit program so the values for the form will be retrieved from a database. How do I set the value of...
5
by: plumba | last post by:
Hi all. I have two drop down menus, the first a list of Departments, the second a list of Sections. Each Department has a set of Setions, so the Sections dropdown contains complete list of all...
2
by: akshalika | last post by:
Hi, I have a repeater control. it dynamically bind textbox or dropdown base on some condition. i want to bind required field validator dynamically for validate textbox or dropdown. here is my...
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
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: 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
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...

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.