DelphiFAQ Home Search:
General :: Web publishing :: JavaScript
Code snippets to add functionality to your HTML pages, preferably cross-browser.


This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Avoid that a HTML FORM is submitted twice


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


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;}"

Generated 4:01:40 on May 31, 2020