How to show hide TextBox on CheckBox check and uncheck in jQuery?
<span>Do you have Passport?</span> <input id="chkConfirm" type="checkbox" /><hr /> <input id="txtPassportNumber" type="text" style="display:none" />
Hi makenzi.exc,
Add the jQuery click event handler to CheckBox and check if checked then show else hide the TextBox.
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 id="chkConfirm" type="checkbox" /><hr /> <input id="txtPassportNumber" type="text" style="display:none" /> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <script type="text/javascript"> $(function () { $("#chkConfirm").click(function () { if ($(this).is(":checked")) { $('#txtPassportNumber').show(); } else { $('#txtPassportNumber').hide(); } }); }); </script> </body> </html>
Demo
Screenshot
Downloads
Download Sample
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.