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
Which property is used to identify the Page is Post Back in ASP.NET?
What is the advantage of using Windows authentication in a Web application?
What is authentication in asp.net?
What language does asp.net use?
What is variable and constant in .net programming language?
Explain the difference between globalization and localization techniques
Is asp.net a language?
What is xaml? Are xaml file compiled or built on runtime?
What is Forms Authentication in ASP.NET?
I have created a configuration setting in my web.config and have kept it at the root level. How do I prevent it from being overridden by another web.config that appears lower in the hierarchy?
What are the ways to show data grid inside a data grid for a master details type of tables? If we write any code for DataGrid methods, what is the access specifier used for that methods in the code behind file and why?
Is asp.net is a programming language?
What is inproc and outproc?
Describe the .net base class library.
What is difference between or and orelse?