Stop users from submitting Gravity Forms form twice

This post is more than 11 years old.

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!