当前位置:主页 > 网页前端 > JavaScript代码 >

js禁止表单重复提交

时间:2021-08-12 09:30:08 | 栏目:JavaScript代码 | 点击:

本文实例为大家分享了js防止表单重复提交实现代码,供大家参考,具体内容如下

<DOCTYPE html>

  <html>
  <BODY BGCOLOR="#FFFFFF">
  <form name='formsubmitf' id ="the" method="post" action="XXX.php">
  <input type='hidden' name='mypretime' value='0'>
  <input type="button" value="写好了" name="button1" class="4round" onclick='formsubmit()'>

  </form>

  

  <script Language='JavaScript'>
  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(' 按一次就够了,请勿重复提交!请耐心等待!谢谢合作!');

  return false;

  }

  document.forms.formsubmitf.submit();

  }

  </script>

  </html>

您可能感兴趣的文章:

相关文章