Home > Web Front-end > JS Tutorial > How to set up js to prohibit repeated submission of forms

How to set up js to prohibit repeated submission of forms

php中世界最好的语言
Release: 2018-04-18 15:26:53
Original
1852 people have browsed it

<DOCTYPEhtml>
  <html>
  <BODYBGCOLOR="#FFFFFF">
  <formname=&#39;formsubmitf&#39;id="the"method="post"action="XXX.php">
  <inputtype=&#39;hidden&#39;name=&#39;mypretime&#39;value=&#39;0&#39;>
  <inputtype="button"value="写好了"name="button1"class="4round"onclick=&#39;formsubmit()&#39;>
  </form>
  <scriptLanguage=&#39;JavaScript&#39;>
  function formsubmit() {
  Today = new Date();
  var NowHour = Today.getHours();
  var NowMinute = Today.getMinutes();
  var NowSecond = Today.getSeconds();
  var mysec = (NowHour*3600)+(NowMinute*60)+NowSecond;
  if((mysec-document.formsubmitf.mypretime.value)>600){
  //600只是一个时间值,就是5分钟内禁止重复提交,值随便 
  document.formsubmitf.mypretime.value=mysec;
  }
  else{
  alert(&#39; 按一次就够了,请勿重复提交!请耐心等待!谢谢合作!&#39;);
  return false;
  }
  document.forms.formsubmitf.submit();
  }
  </script>
  </html>
Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

node.js operates audio and video files to encrypt

detailed explanation of the use of js linked lists

The above is the detailed content of How to set up js to prohibit repeated submission of forms. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template