Jquery插件实现点击获取验证码后60秒内禁止重新获取
先到官网(http://plugins.jquery.com/cookie/ )下载cookie插件,放到相应文件夹,代码如下:
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <title>Examples</title>
- <meta name="description" content="">
- <meta name="keywords" content="">
- <script src="<a href="http://apps.bdimg.com/libs/jquery/1.11.1/jquery.min.js" target="_blank" <a="">http://apps.bdimg.com/libs/jquery/1.11.1/jquery.min.js</a> " ></script>
- <script src="jquery.cookie.js" ></script>
- <style type="text/css">
- * {margin: 0; padding: 0; font-family: "Microsoft Yahei";}
- .captcha-box {width: 360px; height: 34px; margin: 30px; padding: 30px; border: #956E6F 1px dashed; border-radius: 5px; background-color: #FAF2F2;}
- #mobile { float: left; width: 180px; height: 32px; border: #e5e5e5 1px solid; line-height: 32px; text-indent: 8px; outline: none;}
- #getting {float: left; height: 34px; margin-left: -1px; padding: 0 18px; text-align: center; line-height: 34px; border: #e5e5e5 1px solid; background: linear-gradient(0deg, #f4f2f2 0%,#fbf9f9 100%); cursor: pointer; outline: none;}
- </style>
- <script>
- $(function(){
- /*仿刷新:检测是否存在cookie*/
- if($.cookie("captcha")){
- var count = $.cookie("captcha");
- var btn = $('#getting');
- btn.val(count+'秒后可重新获取').attr('disabled',true).css('cursor','not-allowed');
- var resend = setInterval(function(){
- count--;
- if (count > 0){
- btn.val(count+'秒后可重新获取').attr('disabled',true).css('cursor','not-allowed');
- $.cookie("captcha", count, {path: '/', expires: (1/86400)*count});
- }else {
- clearInterval(resend);
- btn.val("获取验证码").removeClass('disabled').removeAttr('disabled style');
- }
- }, 1000);
- }
- /*点击改变按钮状态,已经简略掉ajax发送短信验证的代码*/
- $('#getting').click(function(){
- var btn = $(this);
- var count = 60;
- var resend = setInterval(function(){
- count--;
- if (count > 0){
- btn.val(count+"秒后可重新获取");
- $.cookie("captcha", count, {path: '/', expires: (1/86400)*count});
- }else {
- clearInterval(resend);
- btn.val("获取验证码").removeAttr('disabled style');
- }
- }, 1000);
- btn.attr('disabled',true).css('cursor','not-allowed');
- });
- });
- </script>
- </head>
- <body>
- <div class="captcha-box">
- <input type="text" id="mobile" maxlength="11" placeholder="请输入手机号码">
- <input type="button" id="getting" value="获取验证码">
- </div>
- </body>
- </html>
以上就是本文的全部内容了,希望大家能够喜欢。
参考来源:
Jquery插件实现点击获取验证码后60秒内禁止重新获取
http://www.lai18.com/content/349866.html
Jquery插件实现点击获取验证码后60秒内禁止重新获取的更多相关文章
- jQuery实现发送短信验证码后60秒倒计时
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script sr ...
- 获取验证码,60秒倒计时js
<input type="button" id="btn" value="免费获取验证码" /><script type= ...
- js 点击获取验证码后的倒数60s
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <script ...
- js 验证码 倒计时60秒
js 验证码 倒计时60秒 <input type="button" id="btn" value="免费获取验证码" /> & ...
- javaScript 验证码 倒计时60秒
<input type="button" id="btn" value="免费获取验证码" /> <script type ...
- vue实现验证码倒计时60秒的具体代码
vue实现验证码倒计时60秒的具体代码 <span v-show="show" @click="getCode">获取验证码</span> ...
- JS获取验证码后倒计时不受刷新及关闭影响
HTML部分 <input type="button" id="code_btn" value="获取验证码"> JS部分 // ...
- jQuery实现发送验证码倒计时60秒
前端HMTL: <div class="form_box"> <div class="line mb40"> <div class ...
- iOS-登录发送验证码时60秒倒计时,直接用
__block NSInteger timeout= ; //倒计时时间 KWeakSelf dispatch_queue_t queue = dispatch_get_global_queue(DI ...
随机推荐
- 简单实用的Windows命令(二)
昨天简单的记录了几个非常简单实用的Windows命令,不过我又想起来还有两个我在实际的工作中也是经常用到的命令——PING和IPCONFIG,不过我在工作中的使用都是非常简单的,用PING命令检测对应 ...
- C# RSA 算法
RSA公钥加密算法是1977年由Ron Rivest.Adi Shamirh和LenAdleman在(美国麻省理工学院)开发的.RSA取名来自开发他们三者的名字.RSA是目前最有影响力的公钥加密算法, ...
- 2008server安装Intel I217V网卡驱动
问题:由于在职的是小公司,公司服务器都是DIY的,拒绝采购品牌服务器,所以配件都是自己DIY的,这样就会出现很多兼容性问题,例如服务器主板是AUS B85-PRO-Gamer,装的是服务器系统wind ...
- Servlet的过滤器Filter
Servlet 编写过滤器 Servlet 过滤器可以动态地拦截请求和响应,以变换或使用包含在请求或响应中的信息. 可以将一个或多个 Servlet 过滤器附加到一个 Servlet 或一组 Serv ...
- ComponentCount 与 ControlCount 区别
ShowMessage(panel.ComponentCount.ToString); ShowMessage(panel.ControlCount.ToString);componetcou ...
- 4.0以后的新布局方式GridLayout
<?xml version="1.0" encoding="utf-8"?> <GridLayout xmlns:android=" ...
- {matlab}取二值图像centroid几种方法性能比较
试验很简单,取二值图像的质心,三种方法做比较 1.完全采用矩阵性能不做任何循环操作,对find后的值进行除法与取余操作,从而得到centroid 2.完全采用循环操作,最简单明了 3.结合1,2,对每 ...
- XproerIM-V1,2,12,65475发布。
下载地址:http://yunpan.cn/QTCxKvcpC4Iet 访问密码 9141更新记录:1.登陆面板增加帐号列表功能.
- 关于ES、PES、PS/TS 码流
一.基本概念 )ES ES--Elementary Streams (原始流)是直接从编码器出来的数据流,可以是编码过的视频数据流(H.264,MJPEG等),音频数据流(AAC),或其他编码 ...
- supervisor 配置
1. 生成配置文件$ echo_supervisord_conf > /etc/supervisord.conf 2.修改配置文件vi /etc/supervisord.conf找到[inclu ...