In a page there is dropdown list with the name of the
cities like Bangalore,Pune,Chennai,Other and a text box
that would enable the user to enter the name of the city if
other is selected. How to enable validation on the text box
if other is selected
Answer Posted / swetha v
Hi Friends,
I hope the below solution helps....
1. Please add the required field validator for the texbox.
2. In Page_Load method, we can add the below statement
Dropdownlist.Attributed.Add
("OnChange","javascript:ValidateOtherCity();")
Add the below javascript function on the aspx page
function ValidateOtherCity()
{
var other = window.document.getElementById
("DropdownlistName");
if(other.value == 'Other')
{
ValidatorEnable(RequiredFieldValidatorName,true);
}
else
{
ValidatorEnable(RequiredFieldValidatorName,false);
}
}
| Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
Diff between web user control and web custom control?
What is css and what is it used for?
What is meant by server side scripting?
What are validator? Name the validation controls in asp.net? How do you disable them?
If you want to bind the columns manually within the asp:datagrid tags what kind of tags you have to add.
Should I delete cookies?
How does asp page work?
Explain what are the advantages of asp.net mvc framework? : asp.net mvc
What is the difference between asp.net and mvc?
What is http session state?
Define the term Scavenging in Caching?
What is the main difference between Asp.net and Vb.net?
How does the iis work?
What are the advantages of using sql stored procedures instead of adhoc sql queries in an asp.net web application?
Describe the method to create a permanent cookie?