一個(gè)JavaScript防止表單重復(fù)提交的實(shí)例
更新時(shí)間:2014年10月21日 16:54:24 投稿:whsnow
防止重復(fù)表單提交的方法有很多,本文使用JavaScript來實(shí)現(xiàn)防止表單重復(fù)提交,很簡(jiǎn)單,但很實(shí)用,新手朋友們不要錯(cuò)過
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>防止重復(fù)表單提交</title> <style> #refresh{ display: none; width:200px; height:20px; background-color: #ff0; } </style> <script> var inprocess = false; window.onload = function(){ document.forms["picker"].onsubmit = validateSubmit; document.getElementById("refresh").onclick = startOver; } function validateSubmit () { // 防止重復(fù)的表單提交 if (inprocess) return; inprocess = true; console.log(inprocess); document.getElementById("submitbutton").disabled = true; document.getElementById("refresh").style.display = "block"; document.getElementById("message").innerHTML = "<p>正在processing,稍等</p>"; return false; } function startOver(){ inprocess = false; document.getElementById("submitbutton").disabled = false; document.getElementById("message").innerHTML = ""; document.getElementById("refresh").style.display = "none"; } </script> </head> <body> <form id="picker" method="post" action=""> group1:<input type="radio" name="group1" value="one" /> group2:<input type="radio" name="group1" value="two" /> group3:<input type="radio" name="group1" value="three" /><br /><br /> Input 1: <input type="text" id="intext" /> Input 2: <input type="text" id="intext2" /> Input 3: <input type="text" id="intext3" /> <input type="submit" id="submitbutton" value="send form" /> </form> <div id="refresh"> <p>單擊我</p> </div> <div id="message"></div> </body> </html>
您可能感興趣的文章:
- js防止表單重復(fù)提交的兩種方法
- javascript下阻止表單重復(fù)提交、防刷新、防后退
- js防止表單重復(fù)提交實(shí)現(xiàn)代碼
- js控制再次點(diǎn)擊按鈕之間的間隔時(shí)間可防止重復(fù)提交
- JSP防止網(wǎng)頁刷新重復(fù)提交數(shù)據(jù)的幾種方法
- JavaScript實(shí)現(xiàn)點(diǎn)擊按鈕后變灰避免多次重復(fù)提交
- JSP刷新頁面表單重復(fù)提交問題解決辦法分享
- JS Ajax請(qǐng)求如何防止重復(fù)提交
- jsp 重復(fù)提交問題
- 前端防止用戶重復(fù)提交js實(shí)現(xiàn)代碼示例
相關(guān)文章
css+js實(shí)現(xiàn)部分區(qū)域高亮可編輯遮罩層
下面介紹我在項(xiàng)目中實(shí)現(xiàn)的方式,全屏遮罩,部分區(qū)域可操作,需要的朋友可以參考下2014-03-03關(guān)于JavaScript 數(shù)組你應(yīng)該知道的事情(推薦)
這篇文章主要介紹了JavaScript 數(shù)組,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04JS實(shí)現(xiàn)新浪微博效果帶遮罩層的彈出框代碼
這篇文章主要介紹了JS實(shí)現(xiàn)新浪微博效果帶遮罩層的彈出框代碼,涉及JavaScript響應(yīng)鼠標(biāo)事件動(dòng)態(tài)操作頁面元素的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-10-10JavaScript編寫開發(fā)動(dòng)態(tài)時(shí)鐘
這篇文章主要為大家詳細(xì)介紹了JavaScript編寫開發(fā)動(dòng)態(tài)時(shí)鐘,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-07-07JavaScript 實(shí)現(xiàn)網(wǎng)頁打印處理
JavaScript 實(shí)現(xiàn)網(wǎng)頁打印處理...2007-04-04基于JS簡(jiǎn)單實(shí)現(xiàn)手持彈幕功能+文字抖動(dòng)特效代碼
這篇文章主要介紹了基于JS簡(jiǎn)單實(shí)現(xiàn)手持彈幕功能+文字抖動(dòng)特效代碼,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-03-03javascript實(shí)現(xiàn)粘貼qq截圖功能(clipboardData)
這篇文章主要介紹了javascript實(shí)現(xiàn)粘貼qq截圖功能,利用clipboardData在網(wǎng)頁中實(shí)現(xiàn)截屏粘貼的功能,感興趣的小伙伴們可以參考一下2016-05-05