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 / sai krishna
In aspx page
<asp:DropDownList ID="DropDownList1" runat="server"
Width="176px">
<asp:ListItem>Pune</asp:ListItem>
<asp:ListItem>Chennai</asp:ListItem>
<asp:ListItem>Hyderabad</asp:ListItem>
<asp:ListItem>Other</asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID="TextBox2"
runat="server"></asp:TextBox>
<script language="javascript" type="text/javascript">
var other1 = window.document.getElementById("TextBox2");
other1.disabled = true;
function ValidateOtherCity()
{
var other = window.document.getElementById
("DropDownList1");
var other2 = window.document.getElementById
("TextBox2");
if(other.value == 'Other')
{
other2.disabled = false;
}
else
{
other2.disabled = true;
}
}
</script>
In aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
DropDownList1.Attributes.Add
("OnChange", "javascript:ValidateOtherCity();");
}
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
what is silver light when will we use silver light,
What is .net remoting?
Is it possible to migrate visual interdev design-time controls to asp.net?
What are directives in asp.net? List down all the important directives.
Does google crawl redirects?
How can u deifne the benefits and limitation of using Viewstate for state management?
Is there any property names “isnavigating”?
Web API supports which protocol?
To add a hyperlink column to the DataGrid which tag is used ?
What is rending process in ASP.NET?
Which ASP.NET configuration options are supported in the ASP.NET implementation on the shared web hosting platform?
What is page fragment caching?
Can viewstate be accessed in another page?
Why would a company use an application service provider?
Where session id is stored?