序
一个以js验证表单的简洁的注册登录页面,不多说直接上图
效果
主要文件
完整代码
1 sign_up.html 注册表单
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>sign-up</title> <link rel="stylesheet" href="css/common_form.css"> </head> <body> <header> <div class="header-line"></div> </header> <div class="content"> <img class="content-logo" src="/UploadFiles/2021-04-02/form_logo.png">2 log_in.html 登录表单
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>log-in</title> <link rel="stylesheet" href="css/common_form.css"> </head> <body> <header> <div class="header-line"></div> </header> <div class="content"> <img class="content-logo" src="/UploadFiles/2021-04-02/form_logo.png">3 common_form.css 表单css样式
/*重置样式*/ 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, 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, section, summary, time, mark, audio, video { margin: 0; padding: 0; border: 0 } body { font-family: "微软雅黑"; background: #f4f4f4; } /*header*/ .header-line { width: 100%; height: 4px; background: #0dbfdd; } /*content*/ .content { width: 28%; margin: 70px auto 0; text-align: center; } .content-logo { width: 80px; height: 80px; } .content-title { margin: 10px 0 25px 0; font-size: 2em; color: #747474; font-weight: normal; } .content-form { width: 100%; padding: 36px 0 20px; border: 1px solid #dedede; text-align: center; background: #fff; } .content-form form div { margin-bottom: 19px; } .content-form form .user, .content-form form .password { width: 77%; height: 20px; padding: 10px; font-size: 1em; border: 1px solid #cccbcb; border-radius: 7px; letter-spacing: 1px; } .content-form form input:focus { outline: none; -webkit-box-shadow: 0 0 5px #0dbfdd; box-shadow: 0 0 5px #0dbfdd; } .content-form-signup { width: 84%; margin: 0 auto; padding: 10px; border: 1px solid #cccbcb; border-radius: 7px; font-size: 1em; font-weight: bold; color: #fff; background: #0dbfdd; cursor: pointer; } .content-form-signup:hover { background: #0cb3d0; } .content-form-signup:focus { outline: none; border: 1px solid #0cb3d0; } .content-login-description { margin-top: 25px; line-height: 1.63636364; color: #747474; font-size: .91666667rem; } .content-login-link { font-size: 16px; color: #0dbfdd; text-decoration: none; } /*输入框无内容便提示*/ #remind_1, #remind_2 { width: 76%; margin: 0 auto 2px; text-align: left; font-size: .2em; color: #f00; }4 common_form_test.js 注册登录脚本
// 全局变量a和b,分别获取用户框和密码框的value值 var a = document.getElementsByTagName("input")[0].value; var b = document.getElementsByTagName("input")[1].value; //用户框失去焦点后验证value值 function oBlur_1() { if (!a) { //用户框value值为空 document.getElementById("remind_1").innerHTML = "请输入用户名!"; document.getElementById("change_margin_1").style.marginBottom = 1 + "px"; } else { //用户框value值不为空 document.getElementById("remind_1").innerHTML = ""; document.getElementById("change_margin_1").style.marginBottom = 19 + "px"; } } //密码框失去焦点后验证value值 function oBlur_2() { if (!b) { //密码框value值为空 document.getElementById("remind_2").innerHTML = "请输入密码!"; document.getElementById("change_margin_2").style.marginBottom = 1 + "px"; document.getElementById("change_margin_3").style.marginTop = 2 + "px"; } else { //密码框value值不为空 document.getElementById("remind_2").innerHTML = ""; document.getElementById("change_margin_2").style.marginBottom = 19 + "px"; document.getElementById("change_margin_3").style.marginTop = 19 + "px"; } } //用户框获得焦点的隐藏提醒 function oFocus_1() { document.getElementById("remind_1").innerHTML = ""; document.getElementById("change_margin_1").style.marginBottom = 19 + "px"; } //密码框获得焦点的隐藏提醒 function oFocus_2() { document.getElementById("remind_2").innerHTML = ""; document.getElementById("change_margin_2").style.marginBottom = 19 + "px"; document.getElementById("change_margin_3").style.marginTop = 19 + "px"; } //若输入框为空,阻止表单的提交 function submitTest() { if (!a && !b) { //用户框value值和密码框value值都为空 document.getElementById("remind_1").innerHTML = "请输入用户名!"; document.getElementById("change_margin_1").style.marginBottom = 1 + "px"; document.getElementById("remind_2").innerHTML = "请输入密码!"; document.getElementById("change_margin_2").style.marginBottom = 1 + "px"; document.getElementById("change_margin_3").style.marginTop = 2 + "px"; return false; //只有返回true表单才会提交 } else if (!a) { //用户框value值为空 document.getElementById("remind_1").innerHTML = "请输入用户名!"; document.getElementById("change_margin_1").style.marginBottom = 1 + "px"; return false; } else if (!b) { //密码框value值为空 document.getElementById("remind_2").innerHTML = "请输入密码!"; document.getElementById("change_margin_2").style.marginBottom = 1 + "px"; document.getElementById("change_margin_3").style.marginTop = 2 + "px"; return false; } }5 form_logo.png Logo照片
到这里,一个简单的注册登录页面就完成了,后面会持续更新,使之更强大。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线
暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。
艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。
《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。
更新日志
2024年09月29日
2024年09月29日
- 纪钧瀚《钢琴阅读时光 雨中书店聆听轻音乐》[FLAC/分轨][399.62MB]
- 证声音乐图书馆《走向自然 疗心爵士乐》[320K/MP3][87.4MB]
- 证声音乐图书馆《走向自然 疗心爵士乐》[FLAC/分轨][184.94MB]
- 陈慧娴.2018-Priscilla-Ism演唱会3CD(2024环球红馆40复刻系列)【环球】【WAV+CUE】
- 郑秀文.1999-我应该得到(国)【华纳】【WAV+CUE】
- 陈家慧.2011-钢琴酒吧2CD【龙吟唱片】【WAV+CUE】
- 证声音乐图书馆《雨季 蓝调吉他 Rainy Blues》[320K/MP3][45.01MB]
- 证声音乐图书馆《雨季 蓝调吉他 Rainy Blues》[FLAC/分轨][109.13MB]
- 赞多《序章》[320K/MP3][45.54MB]
- 许巍.2004-每一刻都是崭新的【步升大风】【WAV+CUE】
- 群星.2024-四方馆影视原声带【韶愔音乐】【FLAC分轨】
- 陈雷.1997-安锁咧【金圆唱片】【WAV+CUE】
- 关淑怡.2013-MY.FAVORITE.SK.3CD【环球】【WAV+CUE】
- Sweety.2006-花言乔语【丰华】【WAV+CUE】
- 李恕权.2003-回·20年全精选2CD【SONY】【WAV+CUE】