mercredi 17 février 2021

submit is enabled only if first checkbox is checked [duplicate]

I want to enable submit button when at least one of the checkboxes (which is inside a for loop) is checked.

Currently what happens is, the submit button is enabled only when the first checkbox is checked, if I check the second or third checkbox without selecting the first one it won't enable the submit button.

function EnableSubmitBtn() {

  if (document.getElementsByName("AccountChecked").checked == false) {
    document.getElementById("btnSubmit").disabled = true;
  } else {
    if (document.getElementById("fileSupport").files.length != 0) {
      document.getElementById("btnSubmit").disabled = false;
    }
  }
}
<td>
  <input onclick="EnableSubmitBtn()" name="AccountChecked" id="chkBoxAccNo" type="checkbox" value="@item.accnt_no" style="background:transparent;color:white" />
</td>



Aucun commentaire:

Enregistrer un commentaire