javascript sets mobile phone verification code 60s waiting code

陈政宽~
Release: 2017-06-28 12:44:45
Original
1415 people have browsed it

This article will share with you JS settings for mobile phonesVerification code60s waiting to implement the code, friends who need it can refer to it

html:

Copy after login

JavaScript:

var btn1 = document.querySelector('.btn1'); var tel = document.querySelector('.tel'); var error = document.querySelector('.error'); var time = 60; btn1.onclick = function(){ var name = tel.value; if (name == "") { error.innerHTML='手机号不能为空!'; return; } else { if (!(/^1[3|4|5|7|8]\d{9}$/.test(name))) { error.innerHTML='手机号格式有误.'; return; } } var timer = setInterval(function(){ time--; btn1.innerHTML = time + "秒"; btn1.disabled = true; if (time==0) { time = 60; clearInterval(timer); btn1.innerHTML = "获取验证码"; btn1.disabled = false; } },1000); }
Copy after login

The above is the JS code introduced by the editor to set the mobile phone verification code for 60s and wait for implementation. I hope it will be helpful to everyone. If you If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank you all for your support of the Script House website!

The above is the detailed content of javascript sets mobile phone verification code 60s waiting code. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!