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 ...
随机推荐
- APK Downgrade Method working fine on LINE latest version 6.7.1
Line is one of the most popular messaging Apps, especially in Asia. On March 3 I downgraded the app ...
- px,pt,em,rem
一直对px,pt,em,rem的认识有误区,现整理一下,供参考.之后还得整理下关于dpi相关的知识. px(pixe,像素l):是一个虚拟长度单位,是计算机系统的数字化图像长度单位,如果px要换算成物 ...
- 在Egret实现二维码长按识别
Egret中二维码图片,是在canvas上,无法在微信上长按扫描识别. 由于微信长按识别二维码是截屏扫描原理,所以只要长按当前屏幕任意一张图片,都能够识别当前屏幕上的二维码. 这里把二维码放在ex ...
- 在where条件中使用CASE WHEN 语句
CREATE TABLE TB_Test_Report ( id int identity, stateid int, userid int, username ) ) go ,,'a') ,,'b' ...
- html text加提示语
<input type="text" id="key" name="key" value=" 请输入关键词" on ...
- cocos2d-js 3.0rc0加载游戏引擎时长时间黑屏
如果是原始引擎的话是会比较大一些,但是最终发布的时候我们都建议你打包成release版,这个可以使用cocos命令 cocos compile -p web 来完成轻松打包,会在你的项目目录下创建一个 ...
- jquery ajax load
jQuery load() 方法 jQuery load() 方法是简单但强大的 AJAX 方法. load() 方法从服务器加载数据,并把返回的数据放入被选元素中. 语法: $(selector). ...
- 【软件工程】电梯调度的初步实现 李亚文&&郭莉莉
一.开门见山,代码粘 using System; using System.Collections.Generic; using System.Data; using System.Drawing; ...
- C++中四种转换类型的区别
一.四种转换类型比较: 类型转换有c风格的,当然还有c++风格的.c风格的转换的格式很简单(TYPE)EXPRESSION,但是c风格的类型转换有不少的缺点,有的时候用c风格的转换是不合适的,因为它可 ...
- asp.net mvc 如何将controller 里一个action 返回值为list<>的值输出到view
在controller中:return View(myRole.ToList());在view文件开头加上:@model IEnumerable<LTXYCallCenter.Models.Ro ...