JS implementation Send Verification Code Countdown button

Source: Internet
Author: User

When writing the registration page, it is sometimes necessary to send a registration message to obtain the verification code, but in order to prevent repeated sending of the message,

You must make the button available again after a period of time.

The code is as follows:

1 <HTML> 2 <Head>3 <MetaCharSet= "Utf-8">4 <title>Verification Code Button</title> 5 </Head>6 <Body>7     <Buttontype= "button"ID= "Send">Send Verification Code</Button>8     <Scripttype= "Text/javascript">9 wait=  -;Ten         functionWait_time (btn) { One             if(Wait== 0) { A Btn.removeattribute ("Disabled"); - Btn.innertext= "Send Verification Code"; - wait=  -; the             } Else { - Btn.setattribute ("Disabled", true); - Btn.innertext=wait+"seconds after sending again"; - wait--; + SetTimeout (function() {wait_time (BTN);}, +); -             } +         } A document.getElementById ('Send'). onclick= function() {wait_time ( This)}; at     </Script> - </Body>  - </HTML> 

JS implementation Send Verification Code Countdown button

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.