Javascript sends SMS verification code, and javascript sends SMS

Source: Internet
Author: User

Javascript sends SMS verification code, and javascript sends SMS

This article first analyzes the principle of sending a verification code by mobile phone, and then implements the text message Verification Code sent by javascript. The specific ideas are as follows:
After you click "Send verification code", the buttons are displayed as "retry after 59 seconds" and "retry after 58 seconds "... It is displayed as "Send verification code" after the countdown to 0 seconds ". The button is disabled during the countdown.

Step 1: Get buttons, bind events, set timer variables and timer Variables

Step 2: Add a timerThe timer is reduced by 1 every one second until the timer is cleared when the timer is less than or equal to 0. The button is restored to "Send verification code"; otherwise, the timer is displayed as "Try again after X seconds"

:

Implementation Code:

<! Doctype html> 

Note:

When the set button is disabled, send. disabled = true; send. disabled = false;
Quotation marks are not allowed for true and false! Quotation marks are not allowed for true and false! Quotation marks are not allowed for true and false! Otherwise, the value is always true.
You can also use send. setAttribute ('Disabled ', 'Disabled ');
Or send. removeAttribute ('Disabled ');

The above is all the code for sending text message verification codes for javascript shared by everyone. I hope it will be helpful for everyone's learning.

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.