Skip to content

Instantly share code, notes, and snippets.

@jorgepinon
Last active August 29, 2015 14:10
Show Gist options
  • Save jorgepinon/8e279ddd9e68952a351e to your computer and use it in GitHub Desktop.
Save jorgepinon/8e279ddd9e68952a351e to your computer and use it in GitHub Desktop.
block form double-submission
// jQuery plugin to prevent double submission of forms
jQuery.fn.preventDoubleSubmission = function() {
$(this).on('submit',function(e){
var $form = $(this);
if ($form.data('submitted') === true) {
// don't submit
e.preventDefault();
} else {
// set data attr to true for next time
$form.data('submitted', true);
}
});
// Keep chainability
return this;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment