Disable button when the form is submitting
Description: prevent user double click the submit button
$(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')
});
}
});