分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 软件开发

倒计时,短信发送后倒计时效果js

发布时间:2023-09-06 01:46责任编辑:林大明关键词:js
<div class="input-group-addon"><a style="width: 100%;height: 100%" href="javascript:xiaoyueLogin();" id="verbtn" >获取验证码</a></div>


<script> ???????var InterValObj; //timer变量,控制时间 ???????var count = 60; //间隔函数,1秒执行 ???????var curCount; //当前剩余秒数 ???????$(function () { ??????????$("#verbtn").click(function () {}) ??????????$("#lkchage").click(function () { ??????????????var mobile=$("#nickname").val(); ??????????????var ver = $("#reg_verify").val(); ??????????????if(ver==""){ ??????????????????alert("验证码不能为空"); ??????????????????return; ??????????????} ??????????????$.post("/ucenter/member/foundpassword",{mobile:mobile,reg_verify:ver},function (data) { ???????????????????console.log(data); ??????????????????alert(data.msg); ??????????????????location.href="/ucenter/member/login.html"; ??????????????}) ??????????}) ???????}) ???????function xiaoyueLogin() { ???????????var mobile=$("#nickname").val(); ???????????var reg = /^0?1[3|4|5|8][0-9]\d{8}$/; ???????????if(!mobile){ ???????????????alert(‘手机号不能为空‘); ???????????????return false; ???????????} ???????????if (!reg.test(mobile)) { ???????????????alert(‘手机号码格式不正确‘); ???????????????return false; ???????????} ???????????curCount = count; ???????????$("#verbtn").removeAttr("href"); ???????????$("#verbtn").html("验证码(" + curCount + ")"); ???????????InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器,1秒执行一次 ???????????$.get("/Mob/Message/sendsms?action=1&mobile="+mobile,function (data) { ????????????????alert(data.msg); ???????????????console.log(data.code); ?????????????????if(data.code == 1){} ???????????}) ???????} ???????function SetRemainTime() { ???????????if (curCount == 0) { ???????????????window.clearInterval(InterValObj); //停止计时器 ???????????????$("#verbtn").attr("href", "javascript:xiaoyueLogin();"); ???????????????$("#verbtn").html("重新发送验证码"); ???????????} ???????????else { ???????????????curCount--; ???????????????$("#verbtn").html("验证码(" + curCount + ")"); ???????????} ???????} ???</script>

倒计时,短信发送后倒计时效果js

原文地址:https://www.cnblogs.com/xqschool/p/8622662.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved