


Code sharing for countdown effect of mobile verification code sent by jQuery_jquery
This is a countdown effect code for sending verification codes by mobile phone based on jquery. It can realize the function of real-time display of seconds countdown and the function of verifying the mobile phone number format. It is a commonly used website registration and sending mobile phone verification. code effects code.
Effect description:
When registering a website and needing to send a verification code to your mobile phone, we often encounter this effect:
First check whether the mobile phone conforms to the format of 11 digits starting with 1;
If it does not match, an error message will be prompted and false will be returned;
Otherwise, it is submitted to the background. After the background confirms the reception, a value is returned, and the send button turns gray and counts down.
Operating effect:
--------------------------------Effect demonstration Source code download--------------------------------
The jQuery implementation of the countdown effect code for mobile phones to send verification codes is as follows
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jQuery手机发送验证码倒计时代码</title> <link href="css/jb51.css" type="text/css" rel="stylesheet" /> </head> <body> <div class="form"> <div class="div-name"> <label for="name">用户名</label><input type="text" id="name" class="infos" placeholder="请输入用户名" /> </div> <div class="div-phone"> <label for="phone">手机</label><input type="text" id="phone" class="infos" placeholder="请输入手机" /> <a href="javascript:;" class="send1" onclick="sends.send();">发送验证码</a> </div> <div class="div-ranks"> <label for="ranks">验证码</label><input type="text" id="ranks" class="infos" placeholder="请输入验证码" /> </div> <div class="div-conform"> <a href="javascript:;" class="conform" onclick="sends.conform();">提交</a> </div> </div> <script src="js/jquery-1.8.3.min.js"></script> <script> var sends = { checked:1, send:function(){ var numbers = /^1\d{10}$/; var val = $('#phone').val().replace(/\s+/g,""); //获取输入手机号码 if($('.div-phone').find('span').length == 0 && $('.div-phone a').attr('class') == 'send1'){ if(!numbers.test(val) || val.length ==0){ $('.div-phone').append('<span class="error">手机格式错误</span>'); return false; } } if(numbers.test(val)){ var time = 30; $('.div-phone span').remove(); function timeCountDown(){ if(time==0){ clearInterval(timer); $('.div-phone a').addClass('send1').removeClass('send0').html("发送验证码"); sends.checked = 1; return true; } $('.div-phone a').html(time+"S后再次发送"); time--; return false; sends.checked = 0; } $('.div-phone a').addClass('send0').removeClass('send1'); timeCountDown(); var timer = setInterval(timeCountDown,1000); } } } </script> </body> </html>
The above is the countdown effect code for mobile phone sending verification code implemented by jquery to share with you. I hope you can like it.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

What should I do if Google Chrome does not display the verification code image? Sometimes you need a verification code to log in to a web page using Google Chrome. Some users find that Google Chrome cannot display the content of the image properly when using image verification codes. What should be done? The editor below will introduce how to deal with the Google Chrome verification code not being displayed. I hope it will be helpful to everyone! Method introduction: 1. Enter the software, click the "More" button in the upper right corner, and select "Settings" in the option list below to enter. 2. After entering the new interface, click the "Privacy Settings and Security" option on the left. 3. Then click "Website Settings" on the right

How to use PUT request method in jQuery? In jQuery, the method of sending a PUT request is similar to sending other types of requests, but you need to pay attention to some details and parameter settings. PUT requests are typically used to update resources, such as updating data in a database or updating files on the server. The following is a specific code example using the PUT request method in jQuery. First, make sure you include the jQuery library file, then you can send a PUT request via: $.ajax({u

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: <

In win10, the boot countdown is enabled by default. When we turn on the computer, we will see a countdown interface, usually a 10-second countdown. Within this time, we can choose whether to continue booting or perform some other operations. Although the boot countdown brings some convenience to our system, it may also cause trouble in some cases. I want to cancel the display, but I don’t know how to do it. This article brings you how to cancel the countdown of several seconds after booting up Win10. Understand the win10 boot countdown. In win10, the boot countdown is enabled by default. When we turn on the computer, we will see a countdown interface, usually a 10-second countdown. Within this time, we can choose whether to continue booting or proceed

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

Youkazhong users need to use the verification code to register, so why can’t they receive the verification code to register? Users may not receive the verification code due to network problems, device problems, or server problems. This introduction to the registration problem of not receiving the verification code can tell you how to install it. The following is a detailed introduction, come and take a look! Why can't you receive the verification code for registration in Youka? Answers: Network problems, equipment problems, and server problems lead to detailed introduction: 1. Solution to network problems: Users need to check their own network and can try to change the network environment. If the network is weak, the verification code will fail to be sent. 2. Equipment problem: Solution: Check if there is any interfering software in your background. You can try restarting the device or reinstalling the software.

How to tell if a jQuery element has a specific attribute? When using jQuery to operate DOM elements, you often encounter situations where you need to determine whether an element has a specific attribute. In this case, we can easily implement this function with the help of the methods provided by jQuery. The following will introduce two commonly used methods to determine whether a jQuery element has specific attributes, and attach specific code examples. Method 1: Use the attr() method and typeof operator // to determine whether the element has a specific attribute

jQuery is a popular JavaScript library that is widely used to handle DOM manipulation and event handling in web pages. In jQuery, the eq() method is used to select elements at a specified index position. The specific usage and application scenarios are as follows. In jQuery, the eq() method selects the element at a specified index position. Index positions start counting from 0, i.e. the index of the first element is 0, the index of the second element is 1, and so on. The syntax of the eq() method is as follows: $("s
