京墨六和曲 2021-06-20 22:50 采纳率: 50%
浏览 268
已采纳

html做的登入界面,符合要求但是为什么不能跳转呢

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登入界面</title>
   <style>
     .mydiv{
    margin-top: 250px;
    width: 500px;
    left: 600px;
    height: auto;
    position: absolute;
}
</style>
<script>
  function myclick(){
    var name=document.getElementById("name").value;
    var password=document.getElementById("password").value;
    var patternid=/([a-zA-X0-9]){5,10}/
    var patternpassword=/([[a-zA-X0-9]){5,10}/
    
    if(name==""|| password==""){
        alert("账号或密码不能为空");
    }
    else{
        if(patternid.test(name)){
            if(patternpassword.test(password)){
                documnent.getElementById("form").submit() /*如果账号密码都符合要求再提交*/
                return true;
            }else{
                alert("密码格式不正确,请输入5-10个数字或字母")
            }
        }
        else{
            alert("账号格式不正确,请输入5-10个数字或字母")
        }
    }
 }   
</script>
</head>
<body background="shangu.png" style=" background-repeat:no-repeat ;background-size:100% 100%;
background-attachment: fixed;">
    <form action="user.html" method="POST" id="form" onsubmit="return myclick()">
    <div class="mydiv">
        <div class="login">
            <div class="log-con">
           <p><input type="text" id="name" style="width:250px; height:30px;" placeholder="请输入账号"></p>
            <p><input type="text" id="password" style="width:250px; height:30px;" placeholder="请输入密码"></p>
            <input type="button" value="登录" style="margin-left: 20px;width: 50px;height: 30px;" onclick="myclick()">
            <input type="reset" id="" value="重置" style="margin-left: 60px; width: 50px;height: 30px;">
        </div>
    </div>
</div>
</form>
</body>
</html>
  • 写回答

2条回答 默认 最新

  • CSDN专家-showbo 2021-06-20 23:02
    关注

    documnent.getElementById("form").submit()

     

    document打错了

     

    ==》

    document.getElementById("form").submit()

    帮助到你能点个采纳吗,谢谢~~

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型