I am trying to enable the textbox when checkbox is checked and my coding do like what I want. When submit button clicked it will check the entire form and give error information for every empty field that not been filled and keep the rest information remain to every field that been filled. The problem is, when the checkbox is checked, textbox enabled and been filled, after pressing the submit button (when all required field not completed), the textbox will become disabled with value remained.
Below is coding that I currently use :
<input type="checkbox" name="chklist" onchange="document.getElementById('txtOthers').disabled = !this.checked;" <?php if(isset($_POST['btnSubmit']) && isset($_POST['chklist'])) echo "checked" ?> /> OTHERS :
<input style="width: 130px;" type="textbox" id="txtOthers" name="txtOthers" disabled value="<?php echo $others;?>" />