diff --git a/core/misc/form.js b/core/misc/form.js
index ff134e2..5205b19 100644
--- a/core/misc/form.js
+++ b/core/misc/form.js
@@ -60,6 +60,46 @@ Drupal.behaviors.formUpdated = {
 };
 
 /**
+ * Prevent a form from being submitted several times.
+ */
+Drupal.behaviors.doubleClickPrevention = {
+  attach: function (context) {
+    /**
+     * Disable form submit if it was already submitted before.
+     *
+     * This function will run on all form submit on the page. It will prevent
+     * any form having a 'data-drupal-form-submitted' attribute. In case an
+     * element has the 'data-drupal-form-submit-trigger' it will be disabled.
+     */
+    function preventFormSubmit (e) {
+      var $form = $(e.currentTarget);
+      var $submitButton = $form.find('[data-drupal-form-submit-trigger]');
+      // If there is an element with this data attribute, the form has already
+      // been submitted, prevent second submission.
+      if ($form.attr('data-drupal-form-submitted')) {
+        e.preventDefault();
+      }
+      if ($submitButton.length === 1) {
+        $submitButton.prop('disabled', true);
+        $form.attr('data-drupal-form-submitted', true);
+      }
+    }
+
+    /**
+     * Mark a button as submitted.
+     */
+    function submitClicked (e) {
+      $(e.currentTarget).attr('data-drupal-form-submit-trigger', true);
+    }
+
+    // Disable submit if it was already.
+    $('body').once('doubleClickPrevent').on('submit.preventDoubleSubmit', 'form', preventFormSubmit);
+    // Give user feedback on the form state.
+    $(context).find('form').once('doubleClickPrevent').on('click.preventDoubleSubmit', 'button[type=submit],input[type=submit],input[type=image]', submitClicked);
+  }
+};
+
+/**
  * Prepopulate form fields with information from the visitor cookie.
  */
 Drupal.behaviors.fillUserInfoFromCookie = {
