Click here to Skip to main content
12,689,801 members (26,554 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

55.9K views
4 bookmarked
Posted

Enable Disable Textboxes based on CheckBox using JavaScript

, 10 Dec 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
JavaScript
Welcome again, here is one more trick 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 behave as it is...it's done....

Browse the page and check that out!
Please visit me at ..... http://codeassistant.blogspot.com.

License

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

Share

About the Author

Ravi Tuvar
Technical Lead IntelliMedia Networks, Inc
India India
No Biography provided

You may also be interested in...

Pro
Pro

Comments and Discussions

 
QuestionRegarding to demo Pin
ankitpatel101011-Oct-12 23:28
memberankitpatel101011-Oct-12 23:28 
Questionhi dude .. Pin
ankitpatel101011-Oct-12 23:26
memberankitpatel101011-Oct-12 23:26 
AnswerRe: hi dude .. Pin
Ravi Tuvar14-Oct-12 23:28
memberRavi Tuvar14-Oct-12 23:28 
GeneralReason for my vote of 5 good and simple logic Pin
arun-ice29-Jan-12 22:56
memberarun-ice29-Jan-12 22:56 
GeneralReason for my vote of 5 Good solution - better and more read... Pin
Edward Nutting21-Dec-11 1:24
memberEdward Nutting21-Dec-11 1:24 
Generalmy 5+.. Pin
Prince Antony G13-Dec-11 19:59
memberPrince Antony G13-Dec-11 19:59 
GeneralReason for my vote of 5 simple logic. Pin
Prince Antony G13-Dec-11 19:54
memberPrince Antony G13-Dec-11 19:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170113.4 | Last Updated 10 Dec 2011
Article Copyright 2011 by Ravi Tuvar
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid