(function ($) {
// jQuery plugin to prevent double submission of forms
$.fn.preventDoubleSubmission = function () {
$(this).on('submit', function (e) {
var $form = $(this);
if ($form.data('submitted') === true) {
// Previously submitted - don't submit again
e.preventDefault();
} else {
// Mark it so that the next submit can be ignored
$form.data('submitted', true);
}
});
// Keep chainability
return this;
};
})(jQuery);
$("form").preventDoubleSubmission();
沒有留言:
張貼留言