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

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

用户名6-12位

首字母不能是数字

只能包含字母和数字

密码6-12位

注册页两次密码是否一致

登录HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>My Personal Website-登录.</title>
    <link href="../static/css/js23.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="../static/js/js23.js"></script>

</head>
<body>
<div><h1><span style="font-size: 200px;color: darkmagenta;align:center">"代"</span>你飞!</h1></div>

<div class="box">
    <div>
        <a href="js23.html">登录</a>
        <a style="color: antiquewhite">*</a>
        <a href="js24.html">注册</a>
    </div>
    <br>

    <div class="name" align="center">
        <svg class="iconphone" width="20px" height="20px" viewBox="0 0 20 20">
            <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"
               sketch:type="MSPage">
                <g id="2-copy-2" sketch:type="MSArtboardGroup"
                   transform="translate(-505.000000, -357.000000)" fill="#666">
                    <path d="M517.388314,366.868305 C519.068314,366.001784 520.220053,364.252653 520.220053,362.231784 C520.220053,359.350479 517.883966,357.014392 515.002662,357.014392 C512.121357,357.014392 509.78527,359.350479 509.78527,362.231784 C509.78527,364.252653 510.936575,366.001784 512.616575,366.868305 C508.246575,367.938305 505.002662,371.879175 505.002662,376.57961 C505.002662,376.81961 505.197009,377.014392 505.437444,377.014392 C505.677444,377.014392 505.872227,376.81961 505.872227,376.57961 C505.872227,371.537001 509.960053,367.449175 515.002662,367.449175 C520.04527,367.449175 524.133096,371.537001 524.133096,376.57961 C524.133096,376.81961 524.327444,377.014392 524.567879,377.014392 C524.807879,377.014392 525.002662,376.81961 525.002662,376.57961 C525.002662,371.879175 521.758749,367.938305 517.388314,366.868305 L517.388314,366.868305 Z M510.654835,362.231784 C510.654835,359.830479 512.601357,357.883957 515.002662,357.883957 C517.403966,357.883957 519.350488,359.830479 519.350488,362.231784 C519.350488,364.632653 517.403966,366.57961 515.002662,366.57961 C512.601357,366.57961 510.654835,364.632653 510.654835,362.231784 L510.654835,362.231784 Z"
                          id="id" sketch:type="MSShapeGroup"></path>
                </g>
            </g>
        </svg>
        <input
                id="uname" type="text" placeholder="请输入用户名:">

    </div>
    <br>
    <div class="email" align="center">
        <svg class="iconphone" width="20px" height="20px" viewBox="0 0 20 20">
            <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"
               sketch:type="MSPage">
                <g id="2-copy-2" sketch:type="MSArtboardGroup"
                   transform="translate(-505.000000, -407.000000)" fill="#666">
                    <path d="M515,418.304324 C514.12782,418.304324 513.421091,418.888119 513.421091,419.608723 C513.421091,419.995004 513.624357,420.341947 513.947394,420.580774 L513.947394,421.782554 C513.947394,422.262857 514.418637,422.652187 515.00003,422.652187 C515.581302,422.652187 516.052667,422.262857 516.052667,421.782554 L516.052667,420.580774 C516.375703,420.341947 516.579,419.995004 516.579,419.608723 C516.57897,418.888119 515.87221,418.304324 515,418.304324 L515,418.304324 L515,418.304324 Z M522.368454,414.391327 L521.315788,414.391327 L521.315788,412.217421 C521.315788,409.335657 518.488418,407 515,407 C511.511582,407 508.684212,409.335657 508.684212,412.217421 L508.684212,414.391327 L507.631576,414.391327 C506.178003,414.391327 505,415.364503 505,416.565234 L505,424.826193 C505,426.026824 506.178003,427 507.631576,427 L522.368424,427 C523.821422,427 525,426.026899 525,424.826193 L525,416.565234 C525.00003,415.364478 523.821422,414.391327 522.368454,414.391327 L522.368454,414.391327 L522.368454,414.391327 Z M515,407.869583 C517.906571,407.869583 520.263152,409.816309 520.263152,412.217396 L520.263152,414.391302 L509.737544,414.391302 L509.737544,412.217396 L509.736848,412.217396 C509.736848,409.816309 512.093459,407.869583 515,407.869583 L515,407.869583 L515,407.869583 Z M523.947364,424.826093 C523.947364,425.546622 523.240604,426.130392 522.368454,426.130392 L507.631606,426.130392 C506.759396,426.130392 506.052667,425.546622 506.052667,424.826093 L506.052667,416.565234 C506.052667,415.84468 506.759426,415.260835 507.631606,415.260835 L522.368454,415.260835 C523.240635,415.260835 523.947364,415.844705 523.947364,416.565234 L523.947364,424.826093 L523.947364,424.826093 L523.947364,424.826093 Z"
                          id="pw" sketch:type="MSShapeGroup"></path>
                </g>
            </g>
        </svg>
        <input
                type="password" id="upass" placeholder="请输入密码:">

    </div>
    <br>


    <div id="error_box"></div>
    <div>
        <button id="login" onclick="myLogin()">登录</button>

    </div>
    <br>

    <div>
        <input value="1" name="remember" id="remember" type="checkbox">
        <label for="remember" style="color: darkmagenta">保存登录信息</label>&nbsp;&nbsp;&nbsp;&nbsp;
        <input value="2" name="remember" id="remember" type="checkbox">
        <label for="remember" style="color: darkmagenta">记住我</label>
    </div>

    <br>
    <a class="register-login" href="js24.html">进入注册界面</a>

    <div id="footer" style="background-color: transparent;clear:both;text-align:center;">版权 . duym@jzx</div>
</div>


<script>
    document.getElementById("demo").innerHTML = Date();
    document.write(Date())
</script>

</body>
</html>

登录CSS

 

* {
    margin: 0;
    padding: 0;
    font-family: 微软雅黑;
    font-size: 12px;
}

body {
    background-image: url(http://pic.58pic.com/58pic/14/57/45/91A58PICxYE_1024.jpg);
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
}

div.box {
    font-size: 20px;
    text-align: center;
    margin-left: 600px;
    border-style: hidden;
    background-color: lightgray;
    margin-right: 600px;
    text-align: center;
    color: cornsilk;
    border-radius: 10px;
    padding: 20px;
    bottom: 100px;
    width: 600px;
}



#login {
    color: #fff;
    background: dodgerblue  ;
    border-style: hidden;
    font-size: 40px;
    font-family: 华文行楷;
    width: 360px;
    padding: 9px 18px;
}

.iconphone{
    border-radius: 0px;
    border-style: hidden;
    height: 20px;
    width: 20px;
    padding: 0px;
    background-color:lightgray ;
    border-style: none;


}

.register-login {
    font-size: 30px;
    font-family: 楷体;
    color: blueviolet;

}

#error_box {
    color: red;
}

h1 {
    color: chartreuse;
    font-family: 华文隶书;
    font-size: 100px;
    text-align: center;
}

#uname {
    border-radius: 10px;
    border-style: hidden;
    height: 20px;
    width: 300px;
    padding: 20px;

}

#upass {
    border-radius: 10px;
    border-style: hidden;
    height: 20px;
    width: 300px;
    padding: 20px;

}

#footer {
    color: black;
    font-size: 20px;
}

a:link {
    text-decoration: none;
}
a:hover{
    color: white;
    text-decoration: none;
}

a {
    font-size: 50px;
    font-family: 幼圆;
    color: deepskyblue;
}

登录JavaScript

function myLogin() {
    var oUname = document.getElementById("uname");
    var oUpass = document.getElementById("upass");
    var oError = document.getElementById("error_box");

    oError.innerHTML = "<br>"
    //uname
    if (oUname.value.length > 20 || oUname.value.length < 6) {
        oError.innerHTML = "用户名:6至20位。";
        return;
    } 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(i) < 48 || oUname.value.charCodeAt(i) > 57) && (oUname.value.charCodeAt(i) < 97 || oUname.value.charCodeAt(i) > 122)) {
            oError.innerHTML = "只能是字母或者数字。";
            return;
        }

    }
    //upass
    if (oUpass.value.length > 20 || oUpass.value.length < 6) {
        oError.innerHTML = "密码为6到20位。";
        return;
    }
    window.alert("登录成功!!")

}

运行结果:

注册HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>My Personal Website-注册.</title>
    <link href="../static/css/js24.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="../static/js/js24.js"></script>
</head>
<body>
<div><h1><span style="font-size: 200px;color: darkmagenta;align:center">"代"</span>你飞!</h1></div>

<div class="box">
    <div>
        <a href="js23.html">登录</a>
        <a style="color: antiquewhite">*</a>
        <a href="js24.html">注册</a>
    </div>
    <br>

    <div class="name" align="center">
        <input id="uname" type="text" placeholder="登录账号:">
    </div>
    <br>
    <div class="telephone" align="center">


        <input type="tel"
               id="uuser"
               placeholder="请输入你的手机号:">
    </div>
    <br>

    <div class="email" align="center">
        <input
                type="password" id="upass" placeholder="设置你的密码:">
    </div>
    <br>
    <div class="email" align="center">
        <input
                type="password" id="upass2" placeholder="请输入你的密码:">
    </div>
    <br>
    <div>
        <div id="error_box"></div>
        <div>
            <button id="register" onclick="myRegister()">注册</button>

        </div>
        <a class="login-register" href="js23.html">进入登录界面</a>


        <div id="footer" style="background-color: transparent;clear:both;text-align:center;">版权 . duym@jzx</div>
    </div>
</div>

</body>
</html>

注册CSS

*{
    margin: 0;
    padding: 0;
    font-family: 微软雅黑;
    font-size: 12px;
}
a {
    font-size: 50px;
    font-family: 幼圆;
    color: deepskyblue;
}
body{
    background-image:url(http://pic.58pic.com/58pic/14/57/45/91A58PICxYE_1024.jpg);
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
}

div.box {
    font-size: 20px;
    text-align: center;
    margin-left: 600px;
    border-style: hidden;
    background-color: lightgray;
    margin-right: 600px;
    text-align: center;
    color: cornsilk;
    border-radius: 10px;
    padding: 20px;
    bottom: 100px;
}


.login-register{
    font-size: 30px;
    font-family: 楷体;
    color: blueviolet;

}

#error_box{
    color: red;
    font-size: larger;
}
h1{
    color: chartreuse;
    font-family: 华文隶书;
    font-size: 100px;
    text-align: center;
}
#register{
    color: #fff;
    background: #42c02e;
    border-style: hidden;
    font-size: 40px;
    font-family: 华文行楷;
    width: 340px;
    padding: 9px 18px;

}
#uname{
    border-radius: 10px;
    border-style: hidden;
    height: 10px;
    width: 300px;
    padding: 20px;

}
#upass{
    border-radius: 10px;
    border-style: hidden;
    height: 10px;
    width: 300px;
    padding: 20px;

}
#uuser {
    border-radius: 10px;
    border-style: hidden;
    height: 10px;
    width: 300px;
    padding: 20px;

}
#upass2{
    border-radius: 10px;
    border-style: hidden;
    height: 10px;
    width: 300px;
    padding: 20px;

}
#footer{
    color: black;
    font-size: 20px;
}
a:link{
    text-decoration: none;
}
a:hover{
    color: white;
    text-decoration: none;
}
.iconfont{
    font-family: iconfont!important;
    font-style: normal;
    font-weight: 400!important;
    -webkit-font-smoothing: antialiased;
}

注册JavaScript

function myRegister() {
    var oUname = document.getElementById("uname");
    var oUpass = document.getElementById("upass");
    var oError = document.getElementById("error_box");
    var oUuser = document.getElementById("uuser");
    var oUpass2 = document.getElementById("upass2");

    oError.innerHTML = "<br>"
    //uname
    if (oUname.value.length > 20 || oUname.value.length < 6) {
        oError.innerHTML = "用户名:6至20位。";
        return;
    } 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(i) < 48 || oUname.value.charCodeAt(i) > 57) && (oUname.value.charCodeAt(i) < 97 || oUname.value.charCodeAt(i) > 122)) {
            oError.innerHTML = "昵称只能是字母或者数字。";
            return;
        }
    }
    for (var i = 0; i < 12; i++) {
        if (((oUuser.value.charCodeAt(i) < 48) || (oUuser.value.charCodeAt(i) > 57)) || oUuser.value.length != 11) {
            oError.innerHTML = "请输入正确手机号";
            return;
        }
    }

    //upass
    if (oUpass.value.length > 20 || oUpass.value.length < 6) {
        document.getElementById('error_box').innerHTML = "密码必须在6-20个字符之间";
        return;
    }
    if (oUpass2.value != oUpass.value) {
        oError.innerHTML = "两次输入的密码必须一致";
        return;
    }
    window.alert("注册成功!")

}

运行结果:

登录原图:

 

注册原图:

 

 

转载于:https://www.cnblogs.com/jzx-089/p/7766278.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值