Disabling submit button stops form from being submitted PHP / Javascript

leomacaroni

New Member
I think I got a classic problem but I was not able to find a working solution so far.I have got a form , the user clicks "Send" and everything works fine using a PRG pattern and doing both client-side and server-side validation.The problem arises when any user (let's assume he entered valid inputs) clicks more then once quickly before the server script ends its execution...I do not get any duplicated entry because I took care of that but the browser does not go to my "thanks for submitting page".Instead it re-submits the same page with the same values and what I get are the custom errors I set to warn the user he is trying to enter details already stored in the database. The details sent in the first place are all in the database but the user has no chance to know that.I tried to disable the submit button on a submit event using jQuery but in that case the data are not submitted. HTML\[code\] <div id="send-button-container"> <input id="send-emails" type="submit" name="send_emails" value="http://stackoverflow.com/questions/3883558/Send"/> </div>\[/code\]jQuery\[code\] $(document).ready(function(){ $('#mail-form').submit(function(){ $('#send-emails').attr('disabled','disabled'); }); });\[/code\]I am wondering if I can force a submission using Javascript after disabling the button and also how to deal with UAs with Javascript disabledThanks in advance
 
Back
Top