Skip to content

Instantly share code, notes, and snippets.

@theonlydaleking
Created November 9, 2018 23:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theonlydaleking/06f6b2d151d1af78c586f804d7e29102 to your computer and use it in GitHub Desktop.
Save theonlydaleking/06f6b2d151d1af78c586f804d7e29102 to your computer and use it in GitHub Desktop.
// Prevent Multi Submit on WPCF7 forms
add_action( 'wp_footer', 'mycustom_wp_footer' );
function mycustom_wp_footer() {
?>
<script type="text/javascript">
var disableSubmit = false;
jQuery('input.wpcf7-submit[type="submit"]').click(function() {
jQuery(':input[type="submit"]').attr('value',"Sending...")
if (disableSubmit == true) {
return false;
}
disableSubmit = true;
return true;
})
var wpcf7Elm = document.querySelector( '.wpcf7' );
wpcf7Elm.addEventListener( 'wpcf7submit', function( event ) {
jQuery(':input[type="submit"]').attr('value',"send")
disableSubmit = false;
}, false );
</script>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment