Stop users from submitting Gravity Forms form twice

A common problem with input forms is that users get impatient and click the submit button twice. This can lead to double (or triple, or quadruple!) form submissions, which can really mess things up (especially if you’ve added a billing step to your form!) Stopping it can be surprisingly complex, but here’s a simple piece of browser script that will prevent most users from making multiple submissions with Gravity Forms.

You just need to add this snippet to your site’s JavaScript, whether that be in scripts only loaded with Gravity Forms or with your theme’s scripts.

Of course, whilst this snippet is specifically targeting Gravity Forms, you can easily adapt it for any form: just drop the .gform_wrapper part of the selector. I’m doing it this way because often other plugins / packages already have some way to prevent multiple submissions, and I don’t want to step on their toes!

jQuery(function($) {

//
// prevent Gravity Forms form being submitted twice++
//

var gformSubmitted = false;

$(".gform_wrapper form").submit(function(event) {
    if (gformSubmitted) {
        event.preventDefault();
    }
    else {
        gformSubmitted = true;
        $("input[type='submit']", this).val("Processing, please wait...");
    }
});

});

Job is done, only once, thangyouveramush!

Facebooktwittergoogle_plusredditlinkedinmailFacebooktwittergoogle_plusredditlinkedinmail
  • Mahfuzur Rahman

    Thank you very much. Your code worked fine for me.

  • Pedro Braz

    Is this still working?

    • Maybe not required since GF 1.9; the code still “works” (you can see the button changing) but I think GF is now preventing double-submissions all by itself. At last :)

      • I just installed the latest version (v 1.9.8.19) and it didn’t prevent double submits for me