JavaScript 基础,登录验证

Posted 刘书签

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JavaScript 基础,登录验证相关的知识,希望对你有一定的参考价值。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>javascript</title>
</head>
<body>
    <p id="demo">time</p>
    <script>
        document.write(Date()).innerHTML = aaabbbaa;
        document.getElementById("demo").innerHTML = 123456789;
    </script>
    <button type="button" onclick=window.alert("number")>press</button>

</body>
</html>

<!doctype html>
<html lang="em">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>登录</title>
    <link rel="stylesheet" type="text/css" href="../static/css/styles.css">
    <script>
        function fnLogin() {
            var oUname = document.getElementById("uname")
            var oError = document.getElementById("error_box")
            var oUpass = document.getElementById("upass")
            if(oUname.value.length<6 ){
                oError.innerHTML="用户名至少6位"
            }
            if(oUname.value.length >12){
                oError.innerHTML="用户名最多12位"
            }
            if(oUpass.value.length<6){
                oError.innerHTML="密码至少6位"
            }
            if(oUpass.value.length>12){
                oError.innerHTML="密码最多12位"
            }
        }
    </script>

</head>
<body class="body">

    <div class="box">
        <h2 class="ziti">登录</h2>
        <div class="input_box">
            <input id="uname" type="text" placeholder="请输入用户名">
        </div><br>
        <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>
</html>
 

 

以上是关于JavaScript 基础,登录验证的主要内容,如果未能解决你的问题,请参考以下文章

JavaScript 基础,登录前端验证

JavaScript 基础,登录验证

JavaScript 基础,登录验证

JavaScript 基础,登录验证

JavaScript 基础,登录前端验证

JavaScript 基础,登录前端验证