Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All can anyone help me out How to disable a textbox on client side depending on the selected value in dropdown using javascript

Thank's in advance
Posted
Updated 15-Jul-13 21:16pm
v2

C#
<script language="javascript">
$(document).ready(function(){
$('#<%=dropdown.ClientID%>').change(function(){
var selectedval=$(this).val();
if(selectedval=="1")
$('#<%=txtfirst.ClientID%>').attr("disabled", true);
else if(selectedval=="2")
$('#<%=txtother.ClientID%>').attr("disabled", false);
else
$('#<%=txtfirst.ClientID%>').attr("disabled", false);
});
});
</script>
 
Share this answer
 
Fiddle[^]
Please check the fiddle, this is according to your query.
Hope this helps.
Post back your queries if any.
Thanks.
 
Share this answer
 
Comments
CHill60 25-Dec-14 17:21pm    
You're a year and a half late

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900