Thanks to Jon Leigh for this snippet!  If you use Parsley form validation, a reliable form validation library, here’s an easy way to prevent double submissions of forms.  This disables the form submission button only once the form passes Parsley’s form validation.

$.listen('parsley:form:validated', function(e){
    if (e.validationResult) {
        /* Validation has passed, prevent double submissions */
        $('button[type=submit]').attr('disabled', 'disabled');
  }
});

I’ve implemented this in a few different places and it works flawlessly!  This is especially useful for mobile device users on slow Internet connections where double submissions can be more prevalent.  I hope this helps some businesses out there, it’s helped WordPress Developers and Symfony experts alike improve visitor UX while reducing complaints from people who may have been charged twice.


Check so at least one checkbox on your form is checked before it’s allowed to submit:

$("#main_form").on('submit',function(e){

   if ( $("input[type='checkbox']:checked").length > 0) {

   }
   else {
         e.preventDefault();

         alert("Please check at least one list you wish to be included in.");
         return false;
   }

   return true;

});