#html
<!
DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>霓虹 - 点击打开你的视野</title> <link href="../static/css/denglu.css" rel="stylesheet" type="text/css"> <script type='text/javascript' src='../static/js/denglu.js'></script> </head> <body> <div class="box"> <h1>WELCOME</h1> <h2>登录页面</h2> <div class="input_box"> <input id="uname" type="text" placeholder="请输入用户名" style="width:300px"> </div> <div class="input_box"> <input id="upass" type="password" placeholder="请输入密码" style="width:300px"> </div> </div> <div id="error_box"><br></div> <div class="input_box"> <button onclick="fnLogin()">登录</button><br> <a class="link-forget cl-link-blue"href="get_password.html">忘记密码</a> <a class="link-forget cl-link-blue"href="index.php?type=login">注册</a> </div> </body> </html>
#js
function
fnLogin() { var oUname = document.getElementById("uname") var oError = document.getElementById("error_box") var oUpass = document.getElementById("upass") oError.innerHTML = "<br>" if (oUname.value.length < 6 || oUname.value.length > 20) { oError.innerHTML = "用户名6-20位"; return; } else if ((oUname.value.charCodeAt(0) >= 48) && (oUname.value.charCodeAt(0) <= 57)) { oError.innerHTML = "first letter."; return; } else for (var i = 0; i < oUname.value.length; i++) { if ((oUname.value.charCodeAt(i) < 48) || (oUname.value.charCodeAt(i) > 57) && (oUname.value.charCodeAt(i) < 97) || (oUname.value.charCodeAt(i) > 122)) { oError.innerHTML = "only letter or number"; return; } if (oUpass.value.length < 6 || oUpass.value.length > 12) { oError.innerHTML = "密码6-12位" return; } } window.alert("登录成功!!") }
#css
body{ padding-right:200px; padding-left:200px; color: indianred; padding-top: 40px; font-size: 15px; background: lightpink; font-family:verdana,Arial,Helvetica,sans-serif; } h1{ font-size: 25px; } h2{ padding-left: 100px; }

 posted on 2017-11-01 15:55  048刘思华  阅读(151)  评论(0编辑  收藏  举报