Created
September 26, 2019 22:01
-
-
Save DuckDivers/5153144ed5a06e6034c79f7f4213b642 to your computer and use it in GitHub Desktop.
Prevent Contact Form 7 - Multiple Submissions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Prevent Multiple Clicks on Contact Form 7 Submissions | |
jQuery(document).on('click', '.wpcf7-submit', function(e){ | |
if( jQuery('.ajax-loader').hasClass('is-active') ) { | |
e.preventDefault(); | |
return false; | |
} | |
}); |
This is specifically for class .wpcf7-submit which is for contact form 7.
This solution seems to be no longer effective right now. I guess it's because the .ajax-loader never gets the class "is-active". If someone is facing the same issue, maybe these tweaks helps:
// Prevent Multiple Clicks on Contact Form 7 Submissions
jQuery(document).on('click', '.wpcf7-submit', function(e){
if( jQuery('.wpcf7-form').hasClass('submitting') ) {
e.preventDefault();
return false;
}
});
It's the same logic but I'm relying on the class that CF7 adds to the form, "submitting" (that's basically there until the spinner disappears).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Will this work if I am trying to hide a button to prevent double click entries on BBPress forum responses?