header
 
     
 
pixel
pixel pixel

Disabling form double-submits

I've looked at a lot of javascript tutorials on the web that promise to disable double submits on your HMTL forms. Most are complicated and didn't even work on my system (I use an obscure browser called Internet Explorer). Here is the simplest bit of javascript code that I found worked the best. Just add the following code to your submit button:
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):
<form>
<input type="submit" value="Send" onclick="this.disabled=true,this.form.submit();">
</form>

Unhelpful Helpful Rating 3.8 (score out of 5, no. of ratings: 29)
Comments
Comment by bla on 2007-09-21
comment

Post a Comment
Name
Email
(optional)
Comment
RatingUnhelpful Helpful
Security Image* (this is just to prevent spam submissions)
Security Image