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

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录页面</title>
    <link rel="stylesheet" type="text/css" href="../static/css/1.css">
    <script>
        function fnLogin(){
            var oUname=document.getElementById("uname");
            var oUpass=document.getElementById("upass");
            var oError=document.getElementById("error_box");
            if(oUname.value.length<6 || oUname.value.length>20){
                oError.innerHTML = "用户名要6-20位"
            }else if ((oUname.value.charCodeAt(0)>=48) &&(oUname.value.charCodeAt(0)<=57) ){
                oError.innerHTML="首字母不能是数字";
                return;
            }else for(var i=0;i<=oUname.value.length;i++){
                if(((((oUname.value.charCodeAt(0)>=48) ||(oUname.value.charCodeAt(0)<=57)&& (oUname.value.charCodeAt(0)>=97) ||(oUname.value.charCodeAt(0)<=122))))){
                     oError.innerHTML="只能是字母或数字";
                      return;
                }
            }
            if(oUpass.value.length<6 || oUpass.value.length>20){
                oError.innerHTML = "密码要6-20位"
            }
            if((oUname.value.length<6 || oUname.value.length>20) && (oUpass.value.length<6 || oUpass.value.length>20)){
                oError.innerHTML = "用户名和密码都要6-20位"
            }
        }
    </script>
</head>
<body>
<hr>
<div class="bigdiv">
    <div><h2>登录</h2></div>
    <div>
            用户:<input id="uname" type="text"  placeholder="用户名">
    </div>
    <div>
            密码:<input id="upass" type="password"  placeholder="密码"><br>
    </div>
    <div id="error_box"><br></div>
    <div>
        <button class="button" onclick="fnLogin()">登录</button>
        <button class="button" onclick="register">注册</button>
    </div>
    <div><h3>honghui@</h3></div>

</div>

</body>
</html>

 

 

 

 

posted @ 2017-11-01 15:41  013洪辉  阅读(230)  评论(0编辑  收藏  举报