There is a simple way to disable the submit button while the form’s script processes the fields and submits it. You are utilizing 2 functions to trigger the spinning arrows while the ajax runs.
A line of code in each of these functions will disable the submit button when the spinner becomes visible and then enable it when the spinner/notifications are triggered.
I modified the file includes/js/scirpts.js on one of my installs and it performs wonderfully. Is there any reason why this couldn’t be added for us? I have included the 2 lines I added and the locations to where I added them.
Lines: 15 – 20
adding the following line directly before or after the line toggling the visibility of the .ajax-loader element
$form.find('input.wpcf7-submit').attr('disabled','disabled');
beforeSubmit: function(arr, $form, options) { $form.wpcf7ClearResponseOutput();
$form.find('[aria-invalid]').attr('aria-invalid', 'false');
$form.find('img.ajax-loader').css({ visibility: 'visible' });
return true;
},
Lines: 363 – 369
adding the following line directly before or after the line toggling the visibility of the .ajax-loader element
$(this).find('input.wpcf7-submit').removeAttr('disabled');
$.fn.wpcf7ClearResponseOutput = function() {
return this.each(function() {
$(this).find('div.wpcf7-response-output').hide().empty().removeClass('wpcf7-mail-sent-ok wpcf7-mail-sent-ng wpcf7-validation-errors wpcf7-spam-blocked').removeAttr('role');
$(this).find('span.wpcf7-not-valid-tip').remove();
$(this).find('img.ajax-loader').css({ visibility: 'hidden' });
});
};