jquery获取短信验证码效果
资源介绍
jquery验证码插件介绍:
获取短信验证码效果(jquery),现在很有用户注册的地方为了保证注册用户真实有效,都提供这种验证功能,单击“获取短信验证码”按钮,该按钮会显示成一个到计时的按钮,按钮上显示短信验码的失效时间,时间结束后会显示“重新获取”按钮。
获取发送验证码代码:
<!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>