A way to show form is submitting or stop double click submissions (2.5+) [RESOLVED]

Continuing the discussion from A way to show form is submitting or stop double click submissions:

Hi Chris, does this script/function no longer work with GF 2.5? I have the exact code you provided enabled, and when I click submit, it does change the button text to say “Processing…” but it never actually submits the form. It’s as if clicking the button only changes the button name but then does not allow the submit button to actually submit the entry. Any thoughts on what is going on? Is this handled differently in GF 2.5?

Gravity Forms already have double click protection built-in, so you don’t need to use any script for it.

If you want to show something to indicate the user the form is being submitted, I would recommend you to just enable the Ajax submission for the form (e.g. by adding ajax=“true” if you’re using the shortcode). This will add a spinner next to the button indicating the submission is being processed.

If you really want to show a different text for the submit button after clicking it, you can add the following to your theme’s functions.php file or a custom functions plugin:

add_filter( 'gform_submit_button', 'gf_change_submit_button_text', 10, 2 );
function gf_change_submit_button_text( $button, $form ) {
    $dom = new DOMDocument();
    $dom->loadHTML( '<?xml encoding="utf-8" ?>' . $button );
    $input = $dom->getElementsByTagName( 'input' )->item(0);
    $onclick = $input->getAttribute( 'onclick' );
    $onclick .= " this.value='Sending, please wait...'"; // Change button text when clicked.
    $input->setAttribute( 'onclick', $onclick );
    return $dom->saveHtml( $input );
}

It’s working fine for me in my test site running latest Gravity Forms 2.5.x

1 Like

Thanks Samuel! This works great for us!!

1 Like
© 2008 - 2021. Gravity Forms is a project by Rocketgenius Inc.