How to Prevent Users from Submitting a Form Twice

Once the form is submitted, attach a handler with jQuery that hijacks and “disables” the submit handler:

var $myForm = $("#my_form");
$myForm.submit(function(){
    $myForm.submit(function(){
        return false;
    });
});

Returning “false” from the submit handler will prevent the form from submitting. Disabling buttons can have weird effects on how the form is handled. This approach seems to basically lack side effects and works even on forms that have multiple submit buttons.

Leave a Comment