JS implementation to send SMS Verification Code Countdown tutorial

Source: Internet
Author: User
Tags wrapper

SMS Verification Code countdown can be very good to avoid frequent user access, usually using the JS implementation to obtain SMS Verification code countdown function, the specific implementation of the following:

HTML section:


Page effect:


JS section:


<script>var btndisable = false; Whether the Send button disables Var Btn=document.getelementbyid ("Snsbtn");  Button DOM Object Btn.onclick=function () {//button click event//Prevent wait period execution send   if (btndisable) {       return;    }   1, execute the Request verification code logic   //....   2, set timer and so on   timewait (   3), Recovery button available   btndisable = true;}   function (time) {       setTimeout () {       if (time>=0) {          btn.innerhtml = time + "s after retry";          time--;          Timewait (time);       } else{          btn.innerhtml = "send";          btndisable = false;         }   },1000);  Set Timer   }</script>
Final implementation effect


Reproduced in this article: http://www.lx598.com/hangyedongtai/1028.html

JS implementation to send SMS Verification Code Countdown tutorial

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.