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


Please Help Members By Posting Answers For Below Questions

Define a multilingual website?

530


Explain server side state management system.

547


What is difference between session and viewstate?

469


What is .net framework and what are the main components of it?

370


Define view state.

548






What do you mean by View State and what is its role?

527


Is it possible to apply themes to an asp.net application? If yes, then how?

566


Explain transparent caching with aop?

517


Will the asp.net validators run in server side or client side? How do you do client-side validation in .net? How to disable validator control by client side javascript?

520


What is the compiled object?

1635


What is http response header?

555


What are the different properties of server control that exists?

563


Define tracing.

620


What are the steps to follow to host a web application on a web server?

589


What are resource file and how do we generate resource file?

561