PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Preventing Double Submission of Form

  1. Preventing a user from submitting a form twice and creating multiple entries server side, is a common problem online. I didn't see feature for Gravity Forms to prevent this. So I've tried to figure out a way to use Hooks and Filters to accomplish this. I've read some posts on this, but can't figure out what to do. Nothing seems to work. Anyone have any ideas?

    My two ideas for code now are as follows (why don't these work - nothing happens when I submit the form):
    IDEA1 (Javascript)

    function pre_submission_double($form){
    ?>
    
    <script type="text/javascript"><!--
    function doSubmit() {
        document.gform_1.gform_submit_button_1.disabled = 'disabled';
        document.gform_1.gform_submit_button_1.value = 'Processing. This may take several minutes...';
    }
    //-->
    </script>
    
    <?php
    }
    add_action("gform_pre_submission_1", "pre_submission_double");

    IDEA2 - just change name and maybe add CSS
    -----------------------------------------------------------

    /* Try to Prevent Double Submission by changing name of buttton*/
    function pre_submission_double($form){
        //rename button after submission
        $form["button"]["text"] = 'Processing';
        //returning modified form object
        return $form;
    }
    add_filter("gform_pre_submission_filter_1", "pre_submission_double");
    Posted 12 years ago on Friday April 6, 2012 | Permalink
  2. David Peralty

    Without trying to figure out your code yet, my suggestion is that you could just make it so fields are checked to not allow duplicates.

    To do this, click on a field like a single line text field and check off "No Duplicates". Then a user can't submit something that has already been put into the database. You can select for as many or as few "No Duplicates" fields as you would like.

    Posted 12 years ago on Saturday April 7, 2012 | Permalink
  3. Thanks, I was not aware of the No duplicates feature, but this does not really help us, because our users upload files to the site and if they submit the form twice the same files get uploaded. I have read elsewhere that you can add custom javascript to the submit button, something like "onSubmit" - but I cannot figure out how to use "gform_submit_button" filter. The documentation is very sparce. All I want to do is add an onsubmit function to the submit button. Would I just copy my submit button exactly as it is and just add the onsubmit to the string?

    Posted 12 years ago on Monday April 9, 2012 | Permalink