0

I am having issues re-enabling a field after it being disabled

function disableDate() {
  if (document.getElementById("ongoing").checked = true) {
    document.getElementById("findate").disabled = true;
  } else {
    document.getElementById("findate").disabled = false;
  }
}
<input id="ongoing" type="checkbox" name="educations'[ongoing]" onclick="disableDate()">

<input id="findate" type="text" name="educations[finish_date]" data-date-start-date="0" data-date-autoclose="true" data provide="datepicker" placeholder="Finish Date" />
bertdida
  • 4,988
  • 2
  • 16
  • 22
  • 4
    Your condition is an [assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Assignment) `=` use a [comparison](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness) `===`. – Yoshi Aug 25 '20 at 06:51
  • Which kind of "issues" do you have? Can you explain what exactly is not working, and what you've tried to resolve that problem? – Nico Haase Aug 25 '20 at 09:20

1 Answers1

0

= is for assignment and === is for compare

function disableDate() {
        if(document.getElementById("ongoing").checked){
            document.getElementById("findate").disabled = true;
        }
    else{
        document.getElementById("findate").disabled = false;
    }
}
Baruch Mashasha
  • 951
  • 1
  • 11
  • 29