Last active
August 29, 2015 14:10
-
-
Save jorgepinon/8e279ddd9e68952a351e to your computer and use it in GitHub Desktop.
block form double-submission
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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