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
What are the different ways you would consider sending data across pages in ASP (i.e between asp to asp)?
Explain the difference between server control and html control.
How can you handle exceptions in asp.net?
What are the benefits of Razor View?
When was asp.net released?
Explain the steps needed to be performed in order to create an animation in xaml?
What is preprocessor in .net?
What is http post action?
Explain the namespace classes used in asp.net mvc? : asp.net mvc
What will happen if the server confugration file and the application confugration file have different values for sassion state ASP.NET?
What are the components of ado.net?
We are using Jscriopt validations and at clint site javascript is not running that time validation would work? if yes then how it would behave?
What describes a query?
How long does an http session last?
What is difference between cookies and cache?