为什么return false之后还是会跳转 10
<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>yanzheng</title></head...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>yanzheng</title>
</head>
<body>
<form action="#" method="post" onsubmit="ab()">
用户名:<input type="text" id="inp"><br />
密 码:<input type="password" id="pas"><br />
<input name="" type="submit"/>
<input name="" type="reset" />
</form>
</body>
<script type="text/javascript">
function ab(){
var a=document.getElementById("inp").value;
if (a=="") {
alert("用户名不能为空!");
return false;
}
var b=document.getElementById("pas").value;
if (b=="") {
alert("密码不能为空!");
return false;
}if (b<8) {
alert("密码不能小于8位!")
return false;
}
return false;
}
</script>
</html> 展开
<html lang="en">
<head>
<meta charset="UTF-8">
<title>yanzheng</title>
</head>
<body>
<form action="#" method="post" onsubmit="ab()">
用户名:<input type="text" id="inp"><br />
密 码:<input type="password" id="pas"><br />
<input name="" type="submit"/>
<input name="" type="reset" />
</form>
</body>
<script type="text/javascript">
function ab(){
var a=document.getElementById("inp").value;
if (a=="") {
alert("用户名不能为空!");
return false;
}
var b=document.getElementById("pas").value;
if (b=="") {
alert("密码不能为空!");
return false;
}if (b<8) {
alert("密码不能小于8位!")
return false;
}
return false;
}
</script>
</html> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询