怎样安装Dreamweaver的jquery扩展,我们通常会用dreamweaver这个网页设计软件来编写网页前台代码,在编写代码时会经常出现下拉的菜单供我们选择,为我们编写代码节省了很多的时间。这样......
2023-03-17 342 JQUERY DREAMWEAVER
html css jquery实现注册表单的验证
新建html文档。
书写html。
div class="reg_div">
注册/
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-zd] (.[a-zd] )*@([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("请完善信息");
}
});
页面整体代码结构。
查看效果。
以上方法由办公区教程网编辑摘抄自百度经验可供大家参考!
相关文章
怎样安装Dreamweaver的jquery扩展,我们通常会用dreamweaver这个网页设计软件来编写网页前台代码,在编写代码时会经常出现下拉的菜单供我们选择,为我们编写代码节省了很多的时间。这样......
2023-03-17 342 JQUERY DREAMWEAVER
jQuery MiniUI 快速入门,前段时间由于工作的原因接触到MiiUI。感觉MiiUI很强大,使用起来也很舒服。下面我就带领大家快速的使用MiiUI。MiiUI-专业WeUI控件库它能缩短开发时......
2023-03-17 330 JQUERY
怎么使用JQuery Mobile开发移动网站,现在越来越多的人用网站来做手机a,这样的好处是,可以做一个网站,基本上可以做到多个平台adroid,io,w,都可以使用。这里使用JQueryMoile......
2023-03-17 374 JQUERY