Skip to content

Instantly share code, notes, and snippets.

@wangwen1220
Last active January 2, 2016 13:29
Show Gist options
  • Select an option

  • Save wangwen1220/8310522 to your computer and use it in GitHub Desktop.

Select an option

Save wangwen1220/8310522 to your computer and use it in GitHub Desktop.
js: jQuery 预防对表单进行多次提交 | disabled onsubmit
// jQuery 预防对表单进行多次提交
$(function() {
$('form').submit(function() {
if(typeof jQuery.data(this, "disabledOnSubmit") == 'undefined') {
jQuery.data(this, "disabledOnSubmit", { submited: true });
$('input[type=submit], input[type=button]', this).each(function() {
$(this).attr("disabled", "disabled");
});
return true;
} else {
return false;
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment