js登录界面演示

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>js登录界面演示</title>
    
    </head>
    <body>
        <center>
            <form name="form1" aciton="" method="get">
                <label>用户名:</label><input name="username" type="text" maxlength="20"/>
                <label>密码:</label><input name="pwd" type="password" maxlength="20" />
                <input name="Button" type="button" value="登录" onclick="check()"/>
                <input name="Submit" type="reset" value="重置" />
        </form>
        </center>
    </body>
    <script>
        function check()
        {
            if(form1.username.value=="")  //判断用户名是否为空
            {
                alert("请输入用户名!");
                form1.username.focus();
                return;
            }
            else if(form1.pwd.value==""){  //验证密码是否为空
                alert("请输入密码!");
                form1.pwd.focus();
                return;
            }
            else{
                form1.submit();  //提交表单
            }
        }
    </script>
</html>

原文地址:https://www.cnblogs.com/nanfengnan/p/13939834.html