Skip to content

Instantly share code, notes, and snippets.

@jaredatch
Last active July 20, 2023 17:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredatch/438336f0975acfff5f18bc046eb146d4 to your computer and use it in GitHub Desktop.
Save jaredatch/438336f0975acfff5f18bc046eb146d4 to your computer and use it in GitHub Desktop.
WPForms prevent duplicate / double form entry submissions
<script type="text/javascript">
/**
* Prevent double entry submissions.
*
* Steps to install:
* ​1 - Download and activate the "Insert Headers and Footers" plugin (by WPBeginner)
* 2 - Go to Settings > Insert Headers and Footers
* 3 - Paste this entire code snippet
* 4 - Save
*/
jQuery(function($){
$('.wpforms-form').on('submit',function(e){
var $form = $(this),
validator = $form.validate(),
valid = validator.form();
if (valid) {
if ($form.data('submitted') === true) {
// Previously submitted - don't submit again
alert('Form already submitted. Please wait.');
e.preventDefault();
} else {
// Mark it so that the next submit can be ignored
$form.data('submitted', true);
$form.find(':submit').text('Sending...');
}
}
});
});
</script>
@lazerbaked
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment