<!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>
documnent.getElementById("form").submit()
document打错了
==》
document.getElementById("form").submit()
帮助到你能点个采纳吗,谢谢~~
您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632