js防止表單重復提交

<script language="javascript">   
    var checkSubmitFlg = false;   
    function checkSubmit() {     
        if (!checkSubmitFlg) { 
        checkSubmitFlg = true;     
        return true;  
        }else{
         alert("不能重復提交");
         return false;
        }
     }
</script>

<form action="XXXX" method="POST"   onsubmit="return     checkSubmit()">
  內容:<input type="text" name="content" value=""/><br>
  <input type="submit" value="提交"><br>
</form> 

 

發佈留言