Click here to Skip to main content
15,895,709 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi guys,

pls again me out of this situation.

i have an dropdown list which is mandatory by validation and If dropdown list selected yes then text is visible. i want it will mandatory on selected yes if user select no then it is not mandatory.

pls help how can i do this.
Posted
Comments
[no name] 21-Nov-12 23:48pm    
Could you please provide your dynamic generation of dropdown list.

In subject you mentioned validation for text box but in description asking validation for dropdown list.
Mohd. Mukhtar 22-Nov-12 2:10am    
What have you tried?
Copy your code here by clicking improve question.

1 solution

on the textchange event of dropdownlist control, check whether the dropdownlist selected value is yes, if so display the textbox else dont display it.
Then validate the textbox as,
if (txt1.Visible == true && txt1.Text == "") -- you can validate like this..

or you can validate like,
if(dropdownlist.selectvalue == "Yes" && txt1.Text == "")
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900