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.