Programming C# C++ (7) Delphi (617) Java (8) JavaScript (31) Document (8) Events (8) ExtJS (9) Strings (3) perl (9) php (4) VBScript (1) Visual Basic (1)
Exchange Links About this site Links to us 
|
Avoid that a HTML FORM is submitted twice
5 comments. Current rating: (2 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:
|
anonymous from France
|
 |
|
|
If the user clicks 'back' he opens again the form but it's dead
|
|
anonymous from India
|
|
|
|
goodfix
|
|
anonymous from Uganda
|
 |
|
|
Fanatastic
|
|
anonymous from India
|
|
|
what if the user submits the form using enter button. i am afraid if it still works.
|
|
anonymous from United States
|
|
|
|
hsdherhttht
|
|