您的位置:首页 > Web前端 > HTML5

Html5 获取手机短信号码

2016-06-15 15:44 429 查看
如图:



<!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="js/jquery-1.8.3.js" ></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>


———————————————————————

有需求者请加qq:136137465,非诚勿扰

(java 架构师全套教程,共760G, 让你从零到架构师,每月轻松拿3万)

01.高级架构师四十二个阶段高

02.Java高级系统培训架构课程148课时

03.Java高级互联网架构师课程

04.Java互联网架构Netty、Nio、Mina等-视频教程

05.Java高级架构设计2016整理-视频教程

06.架构师基础、高级片

07.Java架构师必修linux运维系列课程

08.Java高级系统培训架构课程116课时

(送:hadoop系列教程,java设计模式与数据结构, Spring Cloud微服务, SpringBoot入门)

——————————————————————–
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  html5 手机 短信