Enable Disable Textboxes based on CheckBox using JavaScript

by 2:38 AM 0 comments

Welcome again, here is one more trix to enable or disable the multiple textboxes based on the check box event.

Please write the following code in Script area of the page.

 <script type="text/javascript">
    function enableDisable(bEnable, textBoxID, textBoxID2)
    {
         document.getElementById(textBoxID).disabled = !bEnable
         document.getElementById(textBoxID2).disabled = !bEnable
    }
    </script>


Put the controls as shown below in the Form area...

 <asp:TextBox ID="t1" Text="" runat="server" />
            <asp:TextBox ID="t2" Text="" runat="server" />
            <asp:CheckBox ID="chk1" Checked="true" onclick="enableDisable(this.checked, 't1','t2');" runat="server" />

and let it behaves as it is...its done....

browse the page and check that out.!

ravi tuwar

Developer

Cras justo odio, dapibus ac facilisis in, egestas eget quam. Curabitur blandit tempus porttitor. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.

0 comments:

Post a Comment