thecodemine/formwizard — Issue #24: Unable to stop multiple submits.
Author: quincyglenn
Created: 2012-02-03 14:33:47+00:00
State: open

**Great plugin, well developed so I donated again :)**

I have a small issue in which a user can submit a form multiple times (on the last step) if they click the submit button quickly. If using the jQuery form plugin by itself I can disable the submit button before the request is sent and re-enable if validation fails. I am not sure where I can add this functionality using your plugin (without modifying the plugin).
Thanks for your time,
-Q

- A form with id = "#form-create".
- A form with a reset and submit input buttons (used for navigation).
- Using `jQuery.form` plugin.
- Using the `remoteAjax` option.

var submitBtn = $('#form-create').find('input[type="submit"]');
$('#form-create').formwizard({
remoteAjax : remoteAjax,
formPluginEnabled : true,
historyEnabled : false,
focusFirstInput : false,
disableUIStyles : true,
textSubmit : 'Create',
formOptions : {
resetForm : false,
beforeSubmit :
function() {
// Thought this work.
$(submitBtn).attr('disabled', 'disabled');
},
error :
function(jqXHR) {
$(submitBtn).removeAttr('disabled');
that.displayErrors('#form-create', jqXHR);
},
success :
function(json) {
$('#form-create .error').remove();
if (json && json.response) {
alert(json.response['message']);
}
}
}
});