65.9K
CodeProject is changing. Read more.
Home

Enable Disable Textboxes based on CheckBox using JavaScript

starIconstarIconstarIconstarIconstarIcon

5.00/5 (1 vote)

Dec 14, 2011

CPOL
viewsIcon

48370

This code also performs the same functionality: window.onload = function() { var check = document.getElementById(""); check.onchange = function() { if (this.checked == true) ...

This code also performs the same functionality:
<script type="text/javascript">
        window.onload = function() {
            var check = document.getElementById("<%=checkbox1.ClientID %>");
            check.onchange = function() {
                if (this.checked == true)
                    document.getElementById("<%=textbox1.ClientID %>").disabled = false;
                else
                    document.getElementById("<%=textbox1.ClientID %>").disabled = true;
            };
        };
</script>   
<asp:checkbox checked="false" id="checkbox1" runat="server"  />
        <asp:textbox id="textbox1" enabled="false" text="Test" runat="server" />