Jake B Jake B - 2 years ago 120
HTML Question

How to disable / enable an input field with a checkbox

Current code:

<div class="form-group" id="deadline" >
<input type="text" class="datepicker form-control" id="deadline" name="deadline" placeholder="DD/MM/YYYY" >
<input type="checkbox" value="ongoing" name="Ongoing" id="ongoing" >
<label for="ongoing">Ongoing</label>

how do i make it so that checking the "Ongoing" checkbox disables the "deadline" input field?
Thanks ahead of time.

Answer Source

Using jQuery would be easiest way in my opinion

$('#ongoing').change(function() {
  if(this.checked) {
  } else {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download