Jake B Jake B - 7 months ago 39
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.


Using jQuery would be easiest way in my opinion

$('#ongoing').change(function() {
  if(this.checked) {
  } else {