Skip to content

Instantly share code, notes, and snippets.

@andxbes
Created November 23, 2023 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andxbes/83327b1861014e218eabe36be79bfb03 to your computer and use it in GitHub Desktop.
Save andxbes/83327b1861014e218eabe36be79bfb03 to your computer and use it in GitHub Desktop.
CF-7 block submit button on sending
export default function cf_7() {
console.info('cf-7');
let cf_7 = document.querySelectorAll('.wpcf7-form');
if (cf_7 && cf_7.length > 0) {
cf_7.forEach(function (cf_7_form) {
const submit_button = cf_7_form.querySelector('.wpcf7-submit');
if (submit_button) {
cf_7_form.addEventListener('submit', function (event) {
submit_button.setAttribute('disabled', '');
});
cf_7_form.addEventListener('wpcf7submit', function (event) {
submit_button.removeAttribute('disabled');
});
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment