Wednesday, November 5, 2008

prevent double click form submit (double click on form submit problem)

onclick="this.disabled=true;this.form.submit();"

put this at the  end of your submit button.

sample code

<input  type="submit"   value="Submit"  onclick="this.disabled=true,this.form.submit();" />

3 comments:

Unknown said...

yes .it avoids double clicking of submit button but u can go back to form through the browser (back) button which it can submit again.......

ebooksnetworking said...

if that is the case then disable the browser back button.

If you are using spring or struts , you can use token mechanism to handle double click issue.

Professor said...

I think the previous comment authors are missing the point of the script. Isn't it supposed to prevent 'accidental' double clicking? Sometimes, if a form is submitted twice, the consequences could be disastrous. You could be ordering the same merchandise twice!