js验证 为空后为什么还是跳转过去了
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"><html><head><scripttype="tex...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type="text/javascript">
function validate() {
if (document.loginForm.userName.value == null
|| document.loginForm.userName.value == "") {
alert("please input UserName!");
document.loginForm.userName.focus();
return false;
}
if (document.loginForm.password.value == null
|| document.loginForm.password.value == "") {
alert("please input Password!");
document.loginForm.password.focus()
return false;
}
return false;
}
</script>
</head>
<body>
<div align="center">
<h3>
会议管理系统登录
</h3>
<form action="login" method="post" name="loginForm">
UserName:
<input type="text" name="userName" />
<br />
Password:
<input type="text" name="password" />
<br />
<input type="submit" value="提交" onclick="javascript:validate()">
</form>
</div>
</body>
</html> 展开
<html>
<head>
<script type="text/javascript">
function validate() {
if (document.loginForm.userName.value == null
|| document.loginForm.userName.value == "") {
alert("please input UserName!");
document.loginForm.userName.focus();
return false;
}
if (document.loginForm.password.value == null
|| document.loginForm.password.value == "") {
alert("please input Password!");
document.loginForm.password.focus()
return false;
}
return false;
}
</script>
</head>
<body>
<div align="center">
<h3>
会议管理系统登录
</h3>
<form action="login" method="post" name="loginForm">
UserName:
<input type="text" name="userName" />
<br />
Password:
<input type="text" name="password" />
<br />
<input type="submit" value="提交" onclick="javascript:validate()">
</form>
</div>
</body>
</html> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询