Disabling form double-submits

Disabling form double-submits

We can disable double submission by using the following javascript code. We can just add the following code to our 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).

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

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.