Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

Disable button if one of the checkboxes are not checked

const checkBoxes = document.querySelectorAll('input[type="checkbox"]');
const submitButton = document.getElementById('startusing-button');
checkBoxes.forEach((cb) => {
  cb.addEventListener('change', checkButtonStatus);
});
function checkButtonStatus() {
  const checkedCount = [...checkBoxes].filter((cb) => cb.checked);
  submitButton.disabled = checkedCount.length !== checkBoxes.length
}
checkButtonStatus();
 
PREVIOUS NEXT
Tagged: #Disable #button #checkboxes #checked
ADD COMMENT
Topic
Name
5+8 =