Jquery prevent multiple submit

There are two ways of doing this as pointed out by cHao.

$('form button').prop('disabled', true);

or

$('form button').attr('disabled', 'disabled');

Bind and unbind are deprecated in JQuery.

As of jQuery 1.7, the .on() method is the preferred method for attaching event handlers to a document.

http://api.jquery.com/on/

To answer your question about multiple submits, another new addition in JQuery 1.7 is the .one() handler which, attaches an event handler to an object but only allows it to be fired once. This will allow you to prevent multiple submits.

e.g:

$("form#form1").one("submit", submitFormFunction);

function submitFormFunction(event) {
    event.preventDefault(); 
    $("form#form1").submit();
}

Note I'm binding to the form submit event rather than a button click event.

Tags:

Jquery