Skip to content

Instantly share code, notes, and snippets.

@alexkingorg
Last active October 10, 2017 13:16
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alexkingorg/62c55e65a35250512335 to your computer and use it in GitHub Desktop.
Save alexkingorg/62c55e65a35250512335 to your computer and use it in GitHub Desktop.
After form submit, disable submit button.
jQuery(function($) {
// set data-after-submit-value on input:submit to disable button after submit
$(document).on('submit', 'form', function() {
var $form = $(this),
$button,
label;
$form.find(':submit').each(function() {
$button = $(this);
label = $button.data('after-submit-value');
if (typeof label != 'undefined') {
$button.val(label).prop('disabled', true);
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment