zsongs

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();" />

  

发表于 2016-06-20 12:27  LiuYier  阅读(1155)  评论(0编辑  收藏  举报
 

分类:

技术点:

相关文章:

猜你喜欢
  • 2022-01-14
  • 2021-11-30
  • 2021-12-29
  • 2022-01-20
  • 2022-01-18
  • 2021-12-08
  • 2021-06-10
相关资源
相似解决方案