JS SMS Verification Code Countdown effect

Source: Internet
Author: User

<div class= "Input-group" id= "Login_do" ><input type= "num" class= "Form-control inputd" id= "TelCode" Placeholder= "SMS Verification Code"/><span class= "Input-group-addon input-span-black" style= "Display:none" >120s after re-acquisition < /span><span class= "Input-group-addon input-span-white" >&nbsp;</span><a href= "javascript: void (0) "id=" Getcaptcha "class=" Input-group-addon input-span-orange "> Get SMS Verification Code </a><input type=" hidden " Value= "1" name= "Start" id= "Start"/><span class= "Input-group-addon input-span-white" >&nbsp;</span ></div>
<script type= "Text/javascript" >    var start =  document.getElementById (' Start ') .value;    var getcaptcha =  document.getElementById (' Getcaptcha '); Var login_do   = document.getelementbyid (' Login _do ')  ;start = 0;  $ (function () {    if (start == 1) {     startexcute ();}}) Var wait = 120;function timecaptcha (obj)  {         if  (wait == 0)  {        obj.setattribute (" Disabled ",  false);                        obj.innerhtml= "Resend";             login_do.style.background =  "#ff7c8a";             login_do.style.boxShadow =  "0 5px 0 0 # e9717e ";             getcaptcha.style.color =   "#fff";                       wait = 120;        }  else {                     obj.innerHTML= wait +  "Resend after second";             obj.setattribute ("Disabled",  true);             wait--;                        settimeout (function ()  {     &Nbsp;      timecaptcha (obj)              },            1000);             getCaptcha.onclick = null;         }        if (  obj.innerhtml ==  "Resend") {        getcaptcha.onclick =  function  () {        obj.innerhtml= wait +  " Seconds to Resend ";        login_do.style.background = " #dbdbdb ";             login_do.style.boxShadow =  "0  5px 0 0  #cbcbcb ";             getcaptcha.style.color = "#000";             //obj.setattribute ("Disabled",  true);             settimeout (function ()  {            timecaptcha (obj)              },             1000);             getcaptcha.onclick = null;             Resendcaptcha ();        }                 }    }getcaptcha.onclick =  function  () {Timecaptcha (this);} Function startexcute () {getcaptcha.innerhtml= wait +  "resend in Seconds"; Getcaptcha.setattribute ("Disabled",  true);            wait--;             settimeout (function ()  {             timecaptcha (Getcaptcha)              },             1000);             getcaptcha.onclick  = null;} Function resendcaptcha () {var  phone = $ ("#phone"). Val (); var  url =   "{: U (' Register/ajaxsendcode ')}",  $.post (url,{phone:phone},function (data) {/*alert (data)    if (data.error != 0 ) {  showalert ("Zhezhao2", "ShowDiv2", "zhe2");   }*/}, ' JSON '); return false;}


This article is from the "Day South Side" blog, please make sure to keep this source http://phpnan.blog.51cto.com/2641199/1657991

JS SMS Verification Code Countdown effect

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.