Look at a registration get validation countdown effect
Common examples of obtaining authentication codes on cell phone or email
| The code is as follows |
Copy Code |
| <input type= "button" id= "btn" value= "Free access to authentication code"/> <script type= "Text/javascript" > var wait=60; function Time (o) { if (wait = = 0) { O.removeattribute ("Disabled"); O.value= "Free access to verification code"; wait = 60; } else { O.setattribute ("Disabled", true); O.value= "Resend (" + Wait + ")"; wait--; settimeout (function () { Time (O) }, 1000) } } document.getElementById ("Btn"). Onclick=function () {time (this);} </script> |
User Registration Countdown Effect
HTML code
| The code is as follows |
Copy Code |
| <div style= "width:350px; Text-align:center; " > <form name= "RegForm" method= "POST" action= "" > <input type= "Submit" value= "please read the terms of service (0)" disabled= "Disabled" id= "REG_BTN" > <input id= "btnclose" type= "button" value= "I disagree with" onclick= "window.close (); > </form> </div> JS Code <script language= "JavaScript" > <!-- var wait_time = 8; Set number of seconds (in seconds) var secs_time = 0; for (Var i=1;i<=wait_time;i++) { Window.settimeout ("Stimer (" +i+ ")", i*1000); } function Stimer (num) { if (num==wait_time) { document.getElementById ("Reg_btn"). value= "Consent to register"; document.getElementById ("Reg_btn"). Disabled=false; } Else { Secs_time=wait_time-num; document.getElementById ("Reg_btn"). value= "Please read the terms of service first (" +secs_time+ "); } } --> </script> |
Friendly tips, this can achieve a false countdown effect if the user refresh the page can be repeatedly clicked, of course, this needs to be in the server program to judge, this is not introduced here.