js 控制按钮点击后不可用(用于短信或者邮箱验证)
生活随笔
收集整理的這篇文章主要介紹了
js 控制按钮点击后不可用(用于短信或者邮箱验证)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
?過濾一些沒有意向的用戶即虛假用戶。
?獲取驗證碼:
<input type="button" id="btn" value="免費獲取驗證碼" /> <script type="text/javascript"> var wait=60; function time(o) {if (wait == 0) {o.removeAttribute("disabled"); o.value="免費獲取驗證碼";wait = 60;} else {o.setAttribute("disabled", true);o.value="重新發送(" + wait + ")";wait--;setTimeout(function() {time(o)},1000)}} document.getElementById("btn").onclick=function(){time(this);alert('aaaaaa');}</script>收集有效用戶,為了防止用戶多次點擊某按鈕,造成多次提交表單的操作。某些按鈕需要在點擊后實現不可用操作。發送使用ajax實現
? 例子:
<html> <head> <title>同意條款</title> </head> <body> <form id="form1" name="form1" method="post" action=""> <input type="submit" name="Submit" value="同意" /> </form> <script language="javascript"> document.form1.Submit.disabled = true; var wait = 9; //停留時間 function updateinfo(){if(wait == 0){document.form1.Submit.value = "我同意";document.form1.Submit.disabled = false;}else{document.form1.Submit.value = "閱讀條款"+wait;wait--;window.setTimeout("updateinfo()",1000);} } updateinfo(); </script> </body> </html> ? 設置按鈕的不可用 用到了 disabled屬性。
? 語法:
object.disabled = false | true;? 例子:w3cschool
<html> <head> <script type="text/javascript"> function disable(){document.getElementById('txt1').disabled=true;} function enable(){document.getElementById('txt1').disabled=false;} </script> </head> <body><textarea id="txt1"> Hello world....This is a text area </textarea> <br /> <input type="button" onclick="disable()" value="Disable" /> <input type="button" onclick="enable()" value="Enable" /></body> </html>
轉載于:https://my.oschina.net/mickelfeng/blog/109038
總結
以上是生活随笔為你收集整理的js 控制按钮点击后不可用(用于短信或者邮箱验证)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 做Mysql主从时,注意使用replic
- 下一篇: 使用SQL Server Analysi