Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

disable submit button until checkbox is checked javascript

// Retrieve reference to checkbox
const disableCheckBox = document.getElementById("disable-checkbox");
// Retrieve reference to button
const submitButton = document.getElementById("submit-button");

disableCheckBox.addEventListener("change", (e) => {
  if (e.target.checked) {
  	// Disable button when checkbox is selected
    submitButton.disabled = true;
  } else {
    // Enable button when checkbox is deselected
    submitButton.disabled = false;
  }
});
 
PREVIOUS NEXT
Tagged: #disable #submit #button #checkbox #checked #javascript
ADD COMMENT
Topic
Name
1+7 =