<!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>
html做的登入界面,符合要求但是为什么不能跳转呢
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- CSDN专家-showbo 2021-06-20 23:02关注
documnent.getElementById("form").submit()
document打错了
==》
document.getElementById("form").submit()
帮助到你能点个采纳吗,谢谢~~
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 3无用