Disabling Form Double Submission

This section contains a lot of Scripting material for your website.

Disabling Form Double Submission

Postby MT Shahzad on March 12th, 2008, 3:05 pm

I've looked at a lot of javascript tutorials on the web that promise to disable double submits on your HMTL forms. Here is the simplest bit of javascript code that I found worked the best. Just add the following code to your submit button:

Code: Select all
onclick="this.disabled=true,this.form.submit();" 


The javascript is executed the first time someone clicks the submit button. The first bit of code 'this.disabled=true' disables the button so it can't be clicked again. The second bit of code 'this.form.submit()' then submits the form results (the form won't work at all without this code). In the end, your form should look something like this (with your own additional fields in there, of course):

Code: Select all
<form>
<input type="submit" value="Send" onclick="this.disabled=true,this.form.submit();">
</form>
MT Shahzad
Web/Software Developer
http://mts.sw3solutions.com
User avatar
MT Shahzad
Site Admin
 
Posts: 300
Joined: February 29th, 2008, 8:11 am
Location: Muridke, Pakistan

Return to Java Script / VB Script

Who is online

Users browsing this forum: No registered users and 0 guests