Disable button when the form is submitting

Description: prevent user double click the submit button

Source: http://www.hackered.co.uk/articles/asp-net-mvc-query-preventing-multiple-clicks-by-disabling-submit-buttons

$(document).on('submit', 'form', function () {
    var buttons = $(this).find('[type="submit"]');
    if ($(this).valid()) {
        buttons.each(function (btn) {
            $(buttons[btn]).prop('disabled', true);
            $(buttons[btn]).val('Creating.. Plz Wait..')
        });
    } else {
        buttons.each(function (btn) {
            $(buttons[btn]).prop('disabled', false);
            $(buttons[btn]).val('Create')
        });
    }
});

results matching ""

    No results matching ""