短信验证码---重新发送倒计时
来源:互联网 发布:linux 小数比较大小 编辑:程序博客网 时间:2024/05/01 06:19
参考代码:
<!DOCTYPE html><html><head><script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script><script type="text/javascript"> var countdown=60; function settime(obj) { if (countdown == 0) { obj.removeAttribute("disabled"); obj.value="免费获取验证码"; countdown = 60; return; } else { obj.setAttribute("disabled", true); obj.value="重新发送(" + countdown + ")"; countdown--; } setTimeout(function() { settime(obj) } ,1000) } </script><body> <input type="button" id="btn" value="免费获取验证码" onclick="settime(this)" /> </body></html>
实践例子:
<!DOCTYPE html><html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>抢占iPhone7专属预订名额</title><link rel="stylesheet" href="getiphone.css" /></head><body style="width: 100%;height: 100%;background:#fff url(iponeImg/beijing.png) no-repeat center fixed;background-size:100% 100%;text-align: center;"><div class="top"><img src="iponeImg/wenan.png" /></div><h1 class="title"><span></span>上市时间同步发售<span></span><br />首批新苹果30个预订专属名额</h1><form id="activityForm" class="form-horizontal" method="post" action="/wamei/activityController/save.htm"><label><span><img src="iponeImg/yonghu.png" /></span><i></i><input type="text" class="inline-input" id="name" name="name" placeholder="请输入您的真实姓名" datatype="*1-20" errormsg="姓名最多20个中英文字符!" nullmsg="请输入您的真实姓名!" /></label><label><span><img src="iponeImg/dianhua.png" /></span><i></i><input type="text" class="inline-input" id="mobilePhone" name="mobilePhone" placeholder="请输入您的手机号码" datatype="*" errormsg="请输入您的手机号码!" nullmsg="请输入您的手机号码!" /></label><label><span><img src="iponeImg/yanzhengma.png" /></span><i></i><input type="text" id="validateCode" class="inline-input" name="validateCode" placeholder="验证码" datatype="*" errormsg="请输入验证码!" nullmsg="请输入验证码!" style="width:180px;" /><a id="num" mark="1" >获取验证码</a></label><label id="get"><input id="confirm" type="submit" value="提交抢占名额" /></label><label><a href="/wamei/pages/activity/details.html" id="activity">查看活动详情</a></label></form><div class="bottom"><span></span><img src="iponeImg/logo.png" /><span></span></div><div id="success"><div class="successImg"><a class="close"></a><p><img src="iponeImg/chenggong.png" />恭喜提交成功</p><p style="padding-top: 0px;font-size: 23px;">分享一下,安抚激动的心</p></div></div></body></html><!-- scripts --><script src="/wamei/pages/js/jquery.min.js"></script><script src="/wamei/pages/js/jquery.form.js"></script><script src="/wamei/pages/js/bootstrap.min.js"></script><script src="/wamei/pages/js/Validform_v5.3.2.js"></script><script type="text/javascript">$(function(){//提交表单$("#activityForm").Validform({btnSubmit:"#confirm",tiptype:function(msg){if(msg != '' && msg!='通过信息验证!'){alert(msg);}},tipSweep:true,beforeSubmit:function(){saveForm();return false;}});});//只允许在APP内打开function isMobile(){var u = navigator.userAgent;var mobileFlag = u.indexOf('type/tfbrowser') > -1;return mobileFlag;}//手机号码验证$("#mobilePhone").blur(function(){var mobilePhone =$("#mobilePhone").val();var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(17[0]{1})|(15[0-3]{1})|(15[5-9]{1})|(18[0-9]{1}))+\d{8})$/;if(mobilePhone){if(!myreg.test(mobilePhone)){alert("请输入有效的手机号码!");$("#mobilePhone").val("");return ;}}});//发送短信验证码$("#num").click(function(){var mobilePhone =$("#mobilePhone").val();var url="/wamei/activityController/sendValidCode.htm";if(!mobilePhone){alert("请输入您的手机号码!");return ;}var mark = $("#num").attr("mark");if("1"==mark){settime(this);$.post(url,{mobilePhone:mobilePhone},function(html){var data = eval("("+html+")");if(data && data.statusCode==1){console.log("send success!");alert("短信验证码已发送,请查收!");}else{alert(data.msg);}});}});//提交form表单function saveForm(){$("#activityForm").ajaxSubmit({//data: {'columnStr':columnStr},type: 'post',async: false,success: function($data) {var data = eval("("+$data+")");if(data && data.statusCode==1){$("#success").show();}else{alert(data.msg);$("#mobilePhone").val("");}}});}$(".close").click(function(){$("#success").hide();window.location.reload();})//短信后倒计时var countdown=60;function settime(obj) {if (countdown == 0) {$(obj).attr("disabled",false);$(obj).attr("mark","1");$(obj).html("获取验证码");countdown = 60;return;} else {$(obj).attr("disabled", true);$(obj).attr("mark","0");$(obj).html("重新发送(" + countdown + ")");countdown--;}setTimeout(function() {settime(obj) },1000)}//$("#confirm").click(function(){//$("#success").show();//})</script>
1 0
- 短信验证码---重新发送倒计时
- 重新发送短信验证码的web的60秒倒计时的实现
- jquery 倒计时发送短信验证码效果
- iOS发送短信后验证码倒计时
- 短信验证码倒计时
- 短信验证码倒计时
- 短信验证码倒计时
- js实现按钮重新发送验证码倒计时效果
- 使用rxjava2实现验证码重新发送按钮的倒计时
- js实现发送短信验证码后60秒倒计时
- 实现发送短信验证码后60秒倒计时
- jQuery实现发送短信验证码后60秒倒计时
- 点击发送短信验证码按钮后,倒计时60秒
- 短信发送倒计时(以及正则验证)
- 前端模拟发送短信验证倒计时
- JS获取短信验证码button的定时重新发送
- 验证码倒计时发送
- 发送验证码倒计时
- MYSQL单表中各记录总和统计 适用于报表
- iOS中延时执行的几种方式
- OpenCV从入门到放弃(三):Core组件细讲
- Firebreath新建工程的过程及使用
- jquery validate addMethod 自定义验证方法
- 短信验证码---重新发送倒计时
- error C2065: 'IDD_MONDATAREPLYDLG' : undeclared identifier解决方法
- 双色球随机产生-代码
- REDIS学习(6)查看redis状态,以及rdb和aof两种持久化方案的区别
- 工厂三兄弟之简单工厂模式(一)
- spring中bean的生命周期
- Spring消息学习(JMS篇)
- dzzoffice应用zoho插件编辑文档的实现
- SpringMvc与Struts2的对比