获取手机验证码并计时
2015-12-18 10:19
232 查看
<a href="javascript:;" onclick="SendPhoneCode()" id="getpCode">获取手机验证码</a>
<script type="text/javascript">
function SendPhoneCode() {
alert("12");
jQuery("#getpCode").attr("onclick", "return false;").html("正在发送.....");
//timtout方法可以写在AJXC里,等发送短信请求成功后再执行
timtout(jQuery("#getpCode"), new Date().getTime(), 10, "");
}
//发送短信倒计时
function timtout(objs, obj, time, fun) {
var s = time - parseInt((new Date().getTime() - obj) / 1000);
if (s <= 0) {
objs.attr("onclick", fun).html("发送验证码");
return;
}
objs.html(s + "秒后获取")
setTimeout(function () { timtout(objs, obj, time, fun) }, 500);
}
</script>
<script type="text/javascript">
function SendPhoneCode() {
alert("12");
jQuery("#getpCode").attr("onclick", "return false;").html("正在发送.....");
//timtout方法可以写在AJXC里,等发送短信请求成功后再执行
timtout(jQuery("#getpCode"), new Date().getTime(), 10, "");
}
//发送短信倒计时
function timtout(objs, obj, time, fun) {
var s = time - parseInt((new Date().getTime() - obj) / 1000);
if (s <= 0) {
objs.attr("onclick", fun).html("发送验证码");
return;
}
objs.html(s + "秒后获取")
setTimeout(function () { timtout(objs, obj, time, fun) }, 500);
}
</script>
相关文章推荐
- 峰值QPS/QPS/PV/UV/服务器数量/并发数/吐吞量/响应时间计算公式
- php执行svn命令更新代码到服务器
- Requesting a Shared File
- Cleanup failed to process the following paths错误的解决
- Linux指令--head,tail
- ==; equals
- python的unittest框架用例失败重运行解决方法
- Cleanup failed to process the following paths错误的解决
- Linux指令--head,tail
- rtp的封包与拆包h264
- Idea配置
- 整理: php常用函数收集并附解释说明
- Setting Up File Sharing
- JAVA / Scala Multi Class in One Source File
- 关于百度ueditor的工具栏中文乱码的解决方案。
- 笔记一:登录问题
- OC学习 第六节
- UIPIck 时间选择器
- 轻量级JavaEE企业应用实战(八)
- Android 监听键盘的弹起与收缩