How to enable disable TextBox on CheckBox check uncheck in JavaScript.
<span>Do you have Passport?</span> <input id="chkConfirm" type="checkbox" /><hr /> <input id="txtPassportNumber" type="text" disabled="disabled" />
Hi makenzi.exc,
Refer below example.
HTML
<html> <head> <meta charset="utf-8" /> <title></title> <style type="text/css"> body { font-family: Arial; font-size: 10pt; } </style> </head> <body> <span>Do you have Passport?</span> <input type="checkbox" id="chkConfirm" onclick="EnableDisableTextBox()" /><hr /> <input id="txtPassportNumber" type="text" disabled="disabled" /> <script type="text/javascript"> function EnableDisableTextBox() { var checkBox = document.getElementById("chkConfirm"); document.getElementById("txtPassportNumber").disabled = !checkBox.checked; }; </script> </body> </html>
Demo
Screenshot
Downloads
Download Sample
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.