So I have a form that submits to a database and I want to prevent more than one submission if the user clicks the submit button more than once...with a little research this seems easily enough done however none of the solutions I found worked for me as I am using the jquery validationEngine plugin to validate the form client side. It is also watching the button I am trying to disable after the first click.
After a little more googeling I managed to come up with this:
$('#speakerForm').validationEngine('attach', {
onValidationComplete: function(form, status){
if(status == true){
$('input.submitbutton').attr('disabled', 'disabled').attr('value', 'Please Wait...');
return true;
}
}
});
which works fine and dandy for functions until I put what I need in there which is the
$('input.submitbutton').attr('disabled', 'disabled').attr('value', 'Please Wait...');
line...
After clicking with this line in the form clears and it goes back to the top of the page and does not submit any data.
I have tried replacing
onValidationComplete:
with
onSuccess:
to no avail. (and obviously getting rid of the if statement)
Any suggestions would be greatly appreciated...
Also feel free to ask questions as I'm normally quite bad at explaining these things haha...
So after lots of fiddling around eventually I found this:
Prevent double submission of forms in jQuery
It has nothing to do with the validation engine however if you include that plugin and then call it after the (normal) call for the validation engine it seems to prevent double submission.
I have only tested it in chrome so far but it seems legit...