js避免表单重复提交
第一种:用flag标识,下面的代码设置checkSubmitFlg标志:<script language="”javascript”"> var checkSubmitFlg = false; function checkSubmit(){ if(checkSubmitFlg ==true){return false; //当表单被提交过一次后checkSubmitFlg将变为true,根据判断将无法进行提交。} checkSubmitFlg ==true; return true;}< /script ><form name=”form1” method=”post” onsubmit=”return checkSubmit();”> ………..</form>第二种:在onsubmit事件中设置,在第一次提交后使提交按钮失效,代码如下:<form action=”about:blank” method=”post” onsubmit =”getElementById(‘submitInput’).disabled=true; return true;”target=”_blank”> <input type=”submit” id=”submitInput”/> </form> </body></html></script>
页:
[1]