验证码倒计时js
getVarify.js
// 验证码计时——第一种
window.onload = function () {
var send = document.getElementById('send'), //按钮ID
times = 10, // 别忘了改这里
timer = null;
send.onclick = function () {
// 计时开始
send.disabled = true;
timer = setInterval(function () {
times--;
if (times <= 0) {
send.value = '获取验证码';
clearInterval(timer);
times = 5; // 别忘了改这里
send.disabled = false;
} else {
send.value = times + '秒后重试'
send.disabled = true;
} console.log(times)
}, 1000);
// 发送请求获取验证码
console.log("sending...")
}
}// 验证码计时——第二种
// 参数:倒计时秒数, 按钮jquery对象, 倒计时结束时显示的文字
// 可以放到短信发送完毕后的回调函数里
// switchMSG(60, $("#get-verify"), '获取验证码')
function switchMSG(times, ele, txt) {
ele.prop('disabled', true)
var idT = setInterval(function() {
if(times < 1) {
ele.html(txt)
ele.prop('disabled', false)
clearInterval(idT)
} else {
ele.html(times+'s')
times--
}
}, 1000)
}
验证码倒计时js的更多相关文章
- 手机验证 发送验证码倒计时js
html: <input name="Tel" class="weui-input" type="tel" placeholder=& ...
- js 验证码 倒计时60秒
js 验证码 倒计时60秒 <input type="button" id="btn" value="免费获取验证码" /> & ...
- js&jq 发送验证码倒计时
<input type="text" name='' id="btn"> //发送验证码倒计时var wait=30; function t ...
- js,JQ获取短信验证码倒计时
按钮 <a href="javasript:void(0);"onclick="settime(this);">获取手机验证码</a> ...
- 原生 JS 实现手机验证码倒计时
可以使用 pointer-events 来阻止元素成为鼠标事件的 target.html5 新增操作元素 class 类名的方式 classList. classList 方法 add(value): ...
- js之验证码倒计时功能
<!DOCTYPE html> <html > <head> <meta http-equiv="Content-Type" conten ...
- js点击按钮获取验证码倒计时
//发送验证码倒计时 var clock = ''; var nums = 60; var btn; $("#btnGetVerCode").click(function () { ...
- js 发送短信验证码倒计时
html <input type="button" id="btn" value="免费获取验证码" onclick="se ...
- jquery倒计时按钮常用于验证码倒计时
<!doctype html><html><head> <meta charset="utf-8"> <title>jq ...
随机推荐
- php链表笔记:合并两个有序链表
<?php /** * Created by PhpStorm. * User: huizhou * Date: 2018/12/2 * Time: 15:29 */ /** * 合并两个有序链 ...
- VS2012 TFS 解决计算机改名无法连接TFS的问题
闲着没事改了下计算机名字,结果造成TFS无法连接. 报错讯息如下: ---------------------------Microsoft Visual Studio-------------- ...
- Ubuntu安装Maven(转)
原文地址:http://my.oschina.net/hongdengyan/blog/150472 一.环境说明: 操作系统:Ubuntu 14.10(64位) maven:apache-maven ...
- 《DSP using MATLAB》Problem 8.1
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- SprigBoot中的 WebMvcConfigurer与 WebMvcConfigurerAdapter和 WebMvcConfigurationSupport
WebMvcConfigurationAdapter 过时? 在SpringBoot2.0之后的版本中WebMvcConfigurerAdapter过时了,所以我们一般采用的是如下的两种的解决的方法. ...
- 使用 jQuery 设置 disabled 属性与移除 disabled 属性
表单中readOnly和disabled的区别:Readonly只针对input(text/ password)和textarea有效,而disabled对于所有的表单元素都有效,包括select,r ...
- [转]浅谈C#中常见的委托
一提到委托,浮现在我们脑海中的大概是听的最多的就是类似C++的函数指针吧,呵呵,至少我的第一个反应是这样的. 关于委托的定义和使用,已经有诸多的人讲解过,并且讲解细致入微,尤其是张子阳的那一篇.我就不 ...
- 移动端Web适配单位rem的坑,oppo r9手机出现错位bug
我们做了一个抽奖的H5活动页面,被一个oppo R9手机客户反馈,抽奖的转盘错位了.刷新了好几次都不行.网上百度一搜真的有部分安卓手机有坑.赶紧修复bug.分享完整的rem.js代码出来.各位看官自己 ...
- hbase连接linux开发过程
最近近公司被安排做hbase开发,太久没做今天记录下过程 import java.io.IOException; import org.apache.hadoop.conf.Configuration ...
- PetaPoco 基础操作
//初始化数据库连接 var db=new PetaPoco.Database("connectionStringName"); //查询单个值 long count=db.Exe ...