码迷,mamicode.com
首页 > 其他好文 > 详细

完成登录与注册页面的前端

时间:2017-11-01 21:35:10      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:mylog   bottom   script   es2017   html   else   i++   href   src   


完成登录与注册页面的HTML+CSS+JS,其中的输入项检查包括:

用户名6-12位

首字母不能是数字

只能包含字母和数字

密码6-12位

注册页两次密码是否一致

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" type="text/css" href="../static/css/ww.css">
  <script src="../static/js/ww.js"></script>
</head>
<body bgcolor="#a9a9a9">

 <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="myLogin()">登录</button>
   </div>
   </div>
  </div>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <link rel="stylesheet" type="text/css" href="../static/css/ww.css">
 <script src="../static/js/ww.js"></script>
</head>
<body bgcolor="#a9a9a9">

 <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 class="input_box">
           <input id="upass" type="password" placeholder="请再次确认密码">
       </div>
       <div id="error_box"><br></div>
   <div class="input_box">
       <button onclick="myLogin()">注册</button>
   </div>
   </div>
  </div>
</div>
</body>
</html>
h2{
    color:black;
    text-align:center;
}
div{
    margin: 0 auto;
    text-align: center;
    background-color:gold;
     width: 300px;

}

.input_box{
    width: 300px;
    height: 30px;
    border-bottom-width: 2px;
    line-height: 30px;
    font-weight: bold;
    background-color:black;
}
.input_box{
    font-size: 8px;
    font-weight: bold;
    border-color: blanchedalmond;
}
.error_box{
     width: 80px;
    height: 30px;
    border-bottom-width: 2px;
    line-height: 30px;
    font-weight: bold;
    background-color:darkorange;
}
  function fnlogin() {
            var oUname = document.getElementById("uname");
            var oUpass = document.getElementById("upass");
            var oPas=document.getElementById("upas")
            var oError = document.getElementById("error_box");
            oError.innerHTML = "<br>"
            if (oUname.value.length < 6 || oUname.value.length > 12) {
                oError.innerHTML = "name:6-20";
                return;
            }
            else if(oUname.charCodeAt(0)>=48&&oUname.charCodeAt(0)<=57){
                oError.innerHTML="first number.";
                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."
                }
            }
             if(oPas.value!=oPass.value){
                oError.innerHTML=‘密码输入不正确‘
            }

            if (oUpass.value.length < 6 || oUpass.value.length >20) {
                oError.innerHTML = "password:6-20";
                return;
            }
            window.alert("登录成功!")
        }

技术分享       技术分享

完成登录与注册页面的前端

标签:mylog   bottom   script   es2017   html   else   i++   href   src   

原文地址:http://www.cnblogs.com/renninwang/p/7768382.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!