ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
#### **2017-12-1 6:47** #### **author:yang** ~~~ <div class="head"> <img class="head-img" src="img/regist.jpg" /> </div> <!--表单内容--> <div class="regist"> <form method="post" action=""> <ul> <li class="bottom-after"> <i class="icon iconfont icon-denglu-xingming"></i> <input type="text" class="reg-text username" placeholder="请输入身份姓名"> </li> <li class="bottom-after"> <i class="icon iconfont icon-denglu-shenfenzheng"></i> <input type="text" class="reg-text userNum" placeholder="请输入身份证号码"> </li> <li class="bottom-after"> <i class="icon iconfont icon-denglu-xuehao"></i> <input type="text" class="reg-text xuehao" placeholder="请输入学号"> </li> <li class="bottom-after"> <i class="icon iconfont icon-denglu-shouji"></i> <input type="tel" class="reg-text phone" placeholder="请输入手机号码"> <input typr="button" class="reg-yan" value="获取验证号"> </li> <li class="bottom-after"> <i class="icon iconfont icon-denglu-shouji"></i> <input type="text" class="reg-text code-number" placeholder="请输入验证码"> </li> </ul> <input type="button" class="reg-btn" value="注册" /> </form> </div> ~~~ css样式 ~~~ .head{ width: 100%; } .head-img{ width: 100%; } .regist { width: 80%; margin: 25px auto; } .regist ul li { position: relative; width: 100%; height: 48px; } .regist ul li i.iconfont { position: absolute; left: 0; top: 0; line-height: 48px; color: #e3e3e3; z-index: 9; } .regist ul li .reg-text, .regist ul li input[type="text"] { position: absolute; top: 0; left: 0; width: 199%; height: 48px; padding-left: 30px; background: none; border: none; font-size: 14px; z-index: 8; } .regist ul li .reg-yan { width: 30%; height: 26px; margin-top: 11px; float: right; font-size: 12px; text-align: center; background-color: #ffdc44; border: none; border-radius: 10px; } .regist input[type="button"], .reg-btn { width: 100%; height: 44px; margin-top: 25px; border: none; background: #ffdc44; font-size: 16px; color: #fff; border-radius: 22px; } .regist input[type="button"]:active { background: #ffdc44; opacity: 0.8; } ~~~ js代码 ~~~ /*注册*/ $("form :input").blur(function () { var $parent = $(this).parent(); if($(this).is(".username")) { if($.trim(this.value) == "" || $.trim(this.value).length < 2 ){ mui.toast("填写的名字与身份证的姓名不符"); } } }) $("form :input").blur(function () { var $parent = $(this).parent(); if($(this).is(".userNum")) { if($.trim(this.value) == "" || $.trim(this.value).length != 18){ mui.toast("填写的名字与身份证号不符"); } } }) $("form :input").blur(function () { var $parent = $(this).parent(); if($(this).is(".xuehao")) { if($.trim(this.value) == "" || $.trim(this.value).length != 5){ mui.toast("填写的学号不符"); } } }) $(function(){ function isPhoneNo(phone) { var m_phone = /^[1][34578][0-9]{9}$/; return m_phone.test(phone); } $(".reg-yan").click(function(){ if ($(".phone").val() == "") { mui.toast("手机号码不能为空!"); }else if (!isPhoneNo($(".phone").val())){ mui.toast("请输入正确的手机号码!"); } }) $(".reg-btn").click(function() { var phone_text = $(".phone").val(); var code_text = $(".code-number").val(); if (!isPhoneNo(phone_text) || phone_text=="") { mui.toast("请输入正确的手机号码!"); }else if (code_text == ""){ mui.toast("请输入验证码!"); } }) }) ~~~