10.31
Posted 037吴宜珊
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了10.31相关的知识,希望对你有一定的参考价值。
1.
<!DOCTYPE html> <!--suppress ALL --> <html lang="en"> <head> <meta charset="UTF-8"> <title>登录</title> <script> function fnlogin() { var oUname = document.getElementById("uname") var oError = document.getElementById("error_box") if (oUname.value.length < 6) { oError.innerHTML = "用户名至少6位"; return; } else if ((oUname.value.charCodeAt(0) >= 48 && (oUname.value.charCodeAt(0)) <= 57)){ oError.innerHTML = "first letter"; // noinspection JSAnnotator 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 (oUname.value.length > 6 & opassward.value.length < 6) { oError.innerHTML = "密码至少为6位" } } </script> </head> <body> <div class="box"> <h2>登录</h2> <div class="input_box"> <input id="uname" type="text" placeholder="请输入用户名"> </div> <div class="input_box"> <input id="upass" type="password" placeholder="请输入密码"> </div> <div id="error_box"><br></div> <div class="input_box"> <button onclick="fnlogin()">登录</button> </div> </div> </body>
2.html,js,css
body{ background: #ff91ba; padding-right:200px; padding-left:200px; color: #ffa45c; padding-top: 40px; font-size: 16px; background: #e2c6d6; font-family:verdana,Arial,Helvetica,sans-serif; } p{ padding-left: 120px; } h2{ padding-left: 90px; }
function fnLogin() { var oUname = document.getElementById("uname") var oName = document.getElementById("nname") var oError = document.getElementById("error_box") var oUpass = document.getElementById("upass") var ooUpass=document.getElementById("uupass") oError.innerHTML = "<br>" //unname if (oUname.value.length < 6 || oUname.value.length > 20) { oError.innerHTML = "用户名6-12位"; 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; } } //upass if (oUpass.value.length < 6 || oUpass.value.length > 12) { oError.innerHTML = "密码6-12位" return; } //uupass if (ooUpass.value!=oUpass.value) { oError.innerHTML = "重复密码错误" return; } //name if (oName.value.length < 3 || oUpass.value.length > 6) { oError.innerHTML = "昵称2-6位"; 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; } } window.alert("登录成功!") }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>注册</title> <link href="../static/css/14.css" rel="stylesheet" type="text/css"> <script src="../static/js/b.js"></script> </head> <body> <div class="box"> <h2>QQ</h2> <h3>注册</h3> <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 class="input_box"> <input id="uupass" type="password" placeholder="请重复输入密码" style="width:300px"> </div> </div> <br> <div id="error_box"><br></div> <div class="input_box"> <button onclick="fnLogin()">注册</button><br> </div> </div> </body> </html>
以上是关于10.31的主要内容,如果未能解决你的问题,请参考以下文章