Answers.Body: <p>I was able to disable double submission of the form by adding the following to the bottom of the form's TPL file:</p>
  
  <pre><code>{literal}
    &lt;script type="text/javascript"&gt;
      // PREVENT DOUBLE SUBMISSION OF FORM
      CRM.$(function ($) {
        $(document).ready(function () {
          $('form').preventDoubleSubmission();  //block double submission of form
        });
  
        // jQuery plugin to prevent double submission of forms
        $.fn.preventDoubleSubmission = function () {
          CRM.$(this).on('submit', function (e) {
            var $form = $(this);
  
            if ($form.data('submitted') === true) {
              // Previously submitted - don't submit again
              console.log("Form Previously submitted - don't submit again");
              e.preventDefault();
            } else {
              // Mark it so that the next submit can be ignored
              console.log("Form NOT Previously submitted");
              $form.data('submitted', true);
            }
          });
  
          // Keep chainability
          return this;
        };
      });
    &lt;/script&gt;
  {/literal}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-31T19:35:07.530Z
Answers.LastActivityDate: 2018-10-31T19:35:07.530Z
Answers.UserDisplayName: Sleewok
Body: <p>I have a pop-up that loads a form. Currently the user can double click the submit button on the form which results in multiple submissions. This can cause some serious issues depending on the purpose of the form.</p>
  
  <p>Any suggestions on the best way to block double click of submit buttons on forms loaded within pop-ups?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-31T19:02:46.430Z
Comments.Text: Most forms should already be preventing this - can you elaborate on what sort of form this is, perhaps with a screenshot?  Of course, the generic solution is to disable the button by Javascript after it's pressed once, but if there are forms that have this issue in Civi we should get it fixed in core.
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-31T19:30:07.497Z
Comments.Text: This is a custom form created for an extension (using Civi's standard for forms). I ended up using Javascript to block it. However, should it be blocking double clicks by default? Or is it different because I created the quickform?
Comments.UserDisplayName: Sleewok
Tags: <extension><quickform>
Title: Blocking Double Click on Form Submit Button
ThreadText: # Blocking Double Click on Form Submit Button
  
  (Asked by: username_0 on 2018-10-31)
  
  I have a pop-up that loads a form. Currently the user can double click the submit button on the form which results in multiple submissions. This can cause some serious issues depending on the purpose of the form.
  
  Any suggestions on the best way to block double click of submit buttons on forms loaded within pop-ups?
  
  **Tags:** extension, quickform
  
  > **Comments:**
  > **username_1**: Most forms should already be preventing this - can you elaborate on what sort of form this is, perhaps with a screenshot?  Of course, the generic solution is to disable the button by Javascript after it's pressed once, but if there are forms that have this issue in Civi we should get it fixed in core.  
  > **username_0**: This is a custom form created for an extension (using Civi's standard for forms). I ended up using Javascript to block it. However, should it be blocking double clicks by default? Or is it different because I created the quickform?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-10-31. Score: 3 | Accepted answer
  
  I was able to disable double submission of the form by adding the following to the bottom of the form's TPL file:
  
  ```
  {literal}
    <script type="text/javascript">
      // PREVENT DOUBLE SUBMISSION OF FORM
      CRM.$(function ($) {
        $(document).ready(function () {
          $('form').preventDoubleSubmission();  //block double submission of form
        });
  
        // jQuery plugin to prevent double submission of forms
        $.fn.preventDoubleSubmission = function () {
          CRM.$(this).on('submit', function (e) {
            var $form = $(this);
  
            if ($form.data('submitted') === true) {
              // Previously submitted - don't submit again
              console.log("Form Previously submitted - don't submit again");
              e.preventDefault();
            } else {
              // Mark it so that the next submit can be ignored
              console.log("Form NOT Previously submitted");
              $form.data('submitted', true);
            }
          });
  
          // Keep chainability
          return this;
        };
      });
    </script>
  {/literal}
  
  ```
  
  
  ---
  
  