Home  >  Article  >  Web Front-end  >  JavaScript avoids multiple submissions and saves of forms

JavaScript avoids multiple submissions and saves of forms

黄舟
黄舟Original
2016-12-15 10:34:541884browse

Friends who have used forms to submit data and save it should have encountered multiple submission forms that refresh once and submit once. This article introduces a method to avoid the form being submitted and saved multiple times.

1. javascript, set up a Variables are only allowed to be submitted once.


method="post" onsubmit="return checkSubmit();">

2. javascript, will Set the submit button or image to disable

method="post"
 onsubmit="getElById('submitInput')
.disabled = true;
return true;
"> ;
 
  styleId="submitInput"
 src="images/ok_b.gif"
 border="0" />
 
 

After using the above method, You will find that after you submit the form, you will refresh it multiple times. There is only one entry in the database and it will not be saved multiple times.

The above is the content of javascript to avoid multiple submissions and saves of the form. For more related articles, please pay attention to the PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn