html+css+jquery实现注册表单的验证
发表日期: 2020-07-18 16:08:05 浏览次数:124
海盐400电话怎么申请开通【海盐400电话办理流程】海盐400电话月租费多少钱、海盐企业400电话服务热线一年大概多少钱、海盐400电话收费标准报价单【企业4006电话4008电话如何办理开通】
海盐县,隶属于浙江省嘉兴市,是浙江最早的建制县之一,始建于秦。海盐县地处杭州湾西北,距上海118公里、杭州98公里。下辖4街道、5镇,陆地面积534.73平方公里,江口海湾面积537.90平方公里。2010年第六次全国人口普查,全县常住人口为43.09万人。
海盐素以“鱼米之乡、丝绸之府、礼仪之邦、旅游之地”著称。1985年被国务院列入沿海经济开放区,是中国综合实力百强县。2018年11月,入选2018年工业百强县(市)。 2018年12月,入选全国县域经济投资潜力100强。 第二批国家农产品质量安全县。 2019全国营商环境百强县。 第二批节水型社会建设达标县(区)。 2019年12月19日,海盐县入选国家城乡融合发展试验区
html+css+jquery实现注册表单的验证
新建html文档。
书写html。
<div class="reg_div">
<p>注册</p>
<ul class="reg_ul">
<li>
<span>用户名:</span>
<input type="text" name="" value="" placeholder="4-8位用户名" class="reg_user">
<span class="tip user_hint"></span>
</li>
<li>
<span>密码:</span>
<input type="password" name="" value="" placeholder="6-16位密码" class="reg_password">
<span class="tip password_hint"></span>
</li>
<li>
<span>确认密码:</span>
<input type="password" name="" value="" placeholder="确认密码" class="reg_confirm">
<span class="tip confirm_hint"></span>
</li>
<li>
<span>邮箱:</span>
<input type="text" name="" value="" placeholder="邮箱" class="reg_email">
<span class="tip email_hint"></span>
</li>
<li>
<span>手机号码:</span>
<input type="email" name="" value="" placeholder="手机号" class="reg_mobile">
<span class="tip mobile_hint"></span>
</li>
<li>
<button type="button" name="button" class="red_button">注册</button>
</li>
</ul>
</div>
书写css样式。
<style>
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video, button { margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline; font-family: "微软雅黑"; text-decoration: none; color: #000; }
body { min-width: 1200px; }
a:hover { text-decoration: none; }
input { outline: none; }
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; }
body { line-height: 1; }
ol, ul { list-style: none; }
blockquote, q { quotes: none; }
blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; }
table { border-collapse: collapse; border-spacing: 0; }
body { background-color: #333; }
.reg_div { margin: auto; width: 500px; height: 500px; border: 1px solid #333; border-radius: 5px; text-align: center; margin-top: 20px; background-color: #ffffff; }
.reg_div p { padding: 30px 0px; font-size: 30px; }
.reg_ul { width: 100%; }
.reg_ul li { margin: auto; overflow: hidden; width: 100%; margin-top: 10px; }
.reg_ul li span { float: left; width: 100px; text-align: right; display: inline-block; margin: auto; margin-left: 30px; margin-top: 10px; }
.reg_ul li span.tip { margin: 6px 0 0 10px; width: 40px; text-align: left; }
.reg_ul li input { float: left; width: 228px; height: 30px; border: 1px solid #333; border-radius: 3px; padding-left: 20px; outline: medium; margin-left: 10px; }
.reg_ul li button { margin: auto; color: #ffffff; background-color: #333; font-size: 16px; padding: 10px 60px; outline: inherit; border-radius: 3px; cursor: pointer; margin-top: 10px; }
</style>
添加并引用js。
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
书写script.js。
var user_Boolean = false;
var password_Boolean = false;
var varconfirm_Boolean = false;
var emaile_Boolean = false;
var Mobile_Boolean = false;
$('.reg_user').blur(function(){
if ((/^[a-z0-9_-]{4,8}$/).test($(".reg_user").val())){
$('.user_hint').html("✔").css("color","green");
user_Boolean = true;
}else {
$('.user_hint').html("×").css("color","red");
user_Boolean = false;
}
});
$('.reg_password').blur(function(){
if ((/^[a-z0-9_-]{6,16}$/).test($(".reg_password").val())){
$('.password_hint').html("✔").css("color","green");
password_Boolean = true;
}else {
$('.password_hint').html("×").css("color","red");
password_Boolean = false;
}
});
$('.reg_confirm').blur(function(){
if (($(".reg_password").val())==($(".reg_confirm").val())){
$('.confirm_hint').html("✔").css("color","green");
varconfirm_Boolean = true;
}else {
$('.confirm_hint').html("×").css("color","red");
varconfirm_Boolean = false;
}
});
$('.reg_email').blur(function(){
if ((/^[a-z\d]+(\.[a-z\d]+)*@([\da-z](-[\da-z])?)+(\.{1,2}[a-z]+)+$/).test($(".reg_email").val())){
$('.email_hint').html("✔").css("color","green");
emaile_Boolean = true;
}else {
$('.email_hint').html("×").css("color","red");
emaile_Boolean = false;
}
});
$('.reg_mobile').blur(function(){
if ((/^1[34578]\d{9}$/).test($(".reg_mobile").val())){
$('.mobile_hint').html("✔").css("color","green");
Mobile_Boolean = true;
}else {
$('.mobile_hint').html("×").css("color","red");
Mobile_Boolean = false;
}
});
$('.red_button').click(function(){
if(user_Boolean && password_Boolea && varconfirm_Boolean && emaile_Boolean && Mobile_Boolean == true){
alert("注册成功");
}else {
alert("请完善信息");
}
});
页面整体代码结构。
查看效果。
7 月 17 日,在华为云 2020 互联网 5G 创新峰会上,华为云联合虎牙等 5G+X 联创营伙伴,发布了三大联合创新解决方案。
其中,华为云联合虎牙发布了昇腾 AI 内容审核解决方案。基于昇腾全栈创新的能力,加强违规内容的审核与过滤。
华为云联合虎牙发布昇腾AI内容审核解决方案
华为云联合游爱速启发布”5G 云游戏互动直播解决方案 "。围绕 5G 新一代技术,共同打造了 “即点—即看—即玩”云游戏互动体验新模式。
海盐400电话怎么申请开通【海盐400电话办理流程】海盐400电话月租费多少钱、海盐企业400电话服务热线一年大概多少钱、海盐400电话收费标准报价单【企业4006电话4008电话如何办理开通】