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 ...
随机推荐
- 前端开发框架Bootstrap和KnockoutJS
江湖中那场异常惨烈的厮杀,如今都快被人遗忘了.当年,所有的武林同道为了同一个敌人都拼尽了全力,为数不多的幸存者心灰意冷,隐姓埋名,远赴他乡,他们将唯一的希望寄托给时间.少年子弟江湖老,红颜少女的鬓边也 ...
- Linux:去除认证,加速 SSH登录
编辑配置文件 /etc/ssh/sshd_config vim /etc/ssh/sshd_config 找到 UseDNS选项,如果没有注释,将其注释 #UseDNS yes 添加 UseDNS n ...
- NHibernate系列文章四:NHibernate运行时监控
摘要 有三种方式可以实现NHibernate运行时监控,监控的信息包括:执行了的SQL语句.NHibernate执行过程.数据库性能分析.这对我们学习NHibernate有很大的帮助,在工作中也能快速 ...
- javascript高级程序设计--笔记01
概述 JavaScript的实现包含三个部分: 1 核心(ECMAScript) 提供核心语言功能 2 文档对象模型(DOM) 一套提供了访问以及操作网页内容的API 3 浏览器对象模型( ...
- Mycat配置文件rule.xml
打开<MyCAT_HOME>/conf/rule.xml,对应的分片配置截取内容如下: <tableRule name="auto-sharding-rang-mod&qu ...
- C++ dll调用
HINSTANCE PH=LoadLibrary(_T("APlayerCaller.dll")); HWND hwnd = AfxGetMainWnd()->m_hWnd; ...
- 读取assets文件夹下图片(ods_interview)
今天看了一道题,现在总结一下里面使用到的知识点: 1.assets文件的访问: 原文出处:http://blog.csdn.net/fengyuzhengfan/article/details/383 ...
- Android之ADB指令
Android打包过程 aapt Android应用打包工具 adb Android调试桥 下面打包过程,eclipse帮我们自动打包好run as->Android application r ...
- IOS设计模式第一篇之MVC
设计模式的好处:我们可以写出容易理解,重用度很高的代码.降低代码的耦合度,符合软件工程的思想. 设计模式主要分为三类:创造型的:单例和抽象工厂.结构类型的: MVC Decorator, Adapt ...
- (引用 )自动化测试报告HTMLtestrunner
1>下载HTMLTestRunner.py文件,地址为: http://tungwaiyip.info/software/HTMLTestRunner.html Windows平台: 将下载 ...