DelphiFAQ Home Search:

Avoid that a HTML FORM is submitted twice

 

comments10 comments. Current rating: 3 stars (4 votes). Leave comments and/ or rate it.

Question:

What is the best way to make sure a user does not submit a form twice?

Answer:

The easiest way: Disable the submit button in the onclick() event. See the code for that in the box below.

You can also put some code in the form's onsubmit() event, as the second code snippet shows.

<!-- 
  disable the submit button after the first click: 
//-->
<input type="submit" onClick="this.disabled=true">


<!--
  Note: the following goes all in one line. 
  This method sets a 'flag' (this.submitted) to 
  avoid multiple submissions of your form.
//-->

<form action=".." \
 onsubmit="if (this.submitted) return false; \
else { \
this.submitted = true; disableSubmits(this); \
return true;}"

Comments:

2005-12-12, 22:04:54
anonymous from France  
rating
If the user clicks 'back' he opens again the form but it's dead
2006-04-01, 09:39:43
anonymous from India  
goodfix
2008-04-26, 05:53:55
anonymous from Uganda  
rating
Fanatastic
2008-11-04, 08:28:50
anonymous from India  
kb
what if the user submits the form using enter button. i am afraid if it still works.
2009-03-19, 00:56:16
anonymous from United States  
hsdherhttht
2012-06-05, 21:31:18
anonymous from China  
<strong> http://www.coachout..strong> <a href=' http://www.coachout..g>Coach Outlet Online</strong></a><br />
<strong> http://www.coachfac..strong> <a href=' http://www.coachfac..g>Coach Factory</strong></a><br />
<strong> http://www.myloveco..strong> <a href=' http://www.myloveco..g>Coach Outlet Online</strong></a><br />
<strong> http://www.buyincoa..strong> <a href=' http://www.buyincoa..g>Coach Outlet</strong></a><br />
<strong> http://www.cheapcoa..strong> <a href=' http://www.cheapcoa..g>Cheap Coach Handbags</strong></a><br />
<strong> http://www.coachfac..strong> <a href=' http://www.coachfac..g>Coach Factory Outlet</strong></a><br />
<strong> http://www.buycoach..strong> <a href=' http://www.buycoach..g>Coach Outlet Online</strong></a><br />
<strong>www.coachoutletonfactory.net</strong> <a href=' http://www.coachout..g>Coach Factory Outlet</strong></a><br />
<strong>www.coachoutletonline4you.us</strong> <a href=' http://www.coachout..g>Coach Outlet Online</strong></a><br />
<strong>coachfactoryoutletq.net</strong> <a href=' http://www.coachfac..g>Coach Factory</strong></a><br />
<strong>gotocoachoutlets.net</strong> <a href=' http://www.gotocoac..g>Coach Outlet Online</strong></a><br />
2012-11-12, 02:07:41
anonymous from United Kingdom  
2013-02-04, 05:40:49
 
rating
rakdxf <a href=' http://paydayloansbsi.com/ '>payday loans</a> 3847 <a href=' http://paydayloansbsi.ca/ '>payday loan</a> 9726 <a href=' http://paydayloansbsi.co.uk/ '>payday loans</a> DBhav
2013-02-06, 23:18:14
 
rating
wugjssc <a href=' http://buyviagrate.com/ '>how to buy viagra</a> 8328 <a href=' http://buycialiste.com/ '>buy cialis online now</a> tEutB
2015-01-30, 00:15:08
anonymous  
I wish to express my aoipecpatirn to this writer just for rescuing me from this scenario. Right after searching throughout the world-wide-web and getting suggestions which were not helpful, I figured my life was done. Being alive without the approaches to the problems you have solved all through your guideline is a serious case, as well as those which could have adversely affected my career if I had not come across the blog. Your good training and kindness in taking care of almost everything was valuable. I don't know what I would've done if I had not come upon such a stuff like this. I can at this moment relish my future. Thanks a lot very much for your professional and result oriented help. I won't think twice to suggest your blog to any person who should get guidelines about this situation.

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: