js短信验证倒计时

<!DOCTYPE html>
<html>
 <head>
  <meta charset="UTF-8">
  <title></title>
  <style type="text/css">
   *{
    margin: 0;
    padding: 0;
   }
   button{
    width: 100px;
   }
  </style>
  <script type="text/javascript">
   window.onload = function(){
    var btn = document.getElementById(‘btn‘);
    btn.onclick = function(){
     this.disabled = true;
     var count = 5;
     var timer = null;
      timer = setInterval(send,1000);
      function  send(){
      count--;
      if(count>=0){
       btn.innerHTML = ‘还剩‘+count+‘s‘;
      }
      else{
       btn.disabled = false;
       btn.innerHTML = ‘重新发送短信‘;
       clearInterval(timer);
       count=5;
      }
     }
     
    }
    
   }
  </script>
 </head>
 <body>
  <input type="text" /><button id="btn">发送短信验证</button>
 </body>
</html>

原文地址:https://www.cnblogs.com/verayangnakiss/p/8548911.html

时间: 2024-08-01 07:21:04

js短信验证倒计时的相关文章

js 短信验证码倒计时效果

<div class="input-group" id="login_do"> <input type="num" class="form-control inputD" id="telCode" placeholder="短信验证码"/> <span class="input-group-addon input-span-black" 

短信验证倒计时实现(转自http://blog.it985.com/13140.html)

第一步 , 拖两个空间textfiled和button到storyboard上的viewcontroller上. 第二步, 拖线,链接到.h文件中代码如下: @property (weak, nonatomic) IBOutlet UIButton *l_timeButton; 第三步, 在,m文件中为l_timeButton设置监听器,监听点击事件. - (void)viewDidLoad { [super viewDidLoad]; [_l_timeButton addTarget:self

短信验证倒计时60s

$("#zphone").click(function(){ var tel2 = $("#regTel").val(); if(flag.tel){ $.post( "<%=path%>/main/login_regCode.action", {"tel":tel2}, function(data){ if(data){ if(data == "has"){ RemainTime(); } }

短信验证倒计时

// 60秒重新获取 new CountDownTimer(60000, 1000) { @Override public void onTick(long millisUntilFinished) { btn_send_verifi.setText((millisUntilFinished / 1000) + "秒后重新获取"); btn_send_verifi.setEnabled(false); } @Override public void onFinish() { btn_s

js 发送短信验证码倒计时

html <input type="button" id="btn" value="免费获取验证码" onclick="settime(this)" /> js // 短信验证码倒计时var countdown=60;function settime(obj) { if (countdown == 0) { obj.removeAttribute("disabled"); obj.value=&

yii框架实现注册页面短信验证60秒倒计时

先说下简单的,直接用jquery来实现短信验证60秒倒计时,然后在说明在yii框架下怎么实现的. <!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">

React 60s倒计时(发送短信验证按钮)

导入:(antd组件——Form表单) import { Button, Form, Input } from 'antd'; const FormItem = Form.Item; state = { loading: false, yztime: 59, }; //倒计60s count = () => { let { yztime } = this.state; let siv = setInterval(() => { this.setState({ yztime: (yztime--

登录注册时候的,短信验证如何做?JS获取当前时间

首先JS获取当前时间 <script type="text/javascript"> window.onload = function(){ var nowDate = new Date(); var str = nowDate.getFullYear()+"-"+(nowDate.getMonth() + 1)+"-"+nowDate.getDate()+" "+nowDate.getHours()+"

ASP.NET MVC+Bootstrap 实现短信验证

短信验证大家都已经很熟悉了,基本上每天都在接触手机短信的验证码,比如某宝,某东购物,网站注册,网上银行等等,都要验证我们的手机号码真实性.这样做有什么好处呢. 以前咱们在做网站的时候,为了提高用户注册的质量,防止用户恶意注册,都会设置一些小阻碍,如网页验证码.邮件认证等等.但是道高一尺魔高一丈,很快网站的这些设置都被一些网络黑客利用注册机逐一攻破,这些功能也就随之变成了摆设. 但是魔高一丈道高两丈,随着移动设备的普及,短信验证的功能横空出世.他的出现轻松的排除了传统网站验证码的弊端,还提升了网站