下面是我的代码,只做了名字不能为空的部分。问题是当名字为空时,错误信息能够出来,但之后却正常跳转到验证成功的页面,这是为什么啊?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Check</title>
</head>
<body>
<script language="javascript">
function c(){
var n=form1.name.value;
//var p1=form1.pass1.value;
//var p2=form2.pass2.value;
if(n==""){
alert("Name can not be null!");
form1.name.foucs();
return false;
}
}
</script>
<center>
<form name=form1 action=hello.jsp method=post onsubmit="return c();">
Name:
<input type=text name=name><br>
Password1:
<input type=password name=pass1><br>
Password2:
<input type=password name=pass2><br>
<input type=submit value=submit>
</form>
</center>
</body>
</html>