JS 防止表单重复提交

<script type="text/javascript">
var checkSubmitFlg = false;
function checkSubmit() {
 if (!checkSubmitFlg) {

// 第一次提交
  checkSubmitFlg = true;
  return true;
 } else {

//重复提交
  alert("Submit again!");
  return false;
 }
}
</script>

//以下三种方式分别调用

<form onsubmit="return checkSubmit();">

<input type="submit" onclick="return checkSubmit();" />

<input type="button" onclick="document.forms[0].action='./test';document.forms[0].submit();return checkSubmit();" />

  

原文地址:https://www.cnblogs.com/zsongs/p/5600191.html