jsp onsubmit不执行,form直接提交,为神魔?? 跪求大神解答,在线等! 下面是jsp内容
<%@pagelanguage="java"contentType="text/html;charset=UTF-8"pageEncoding="GB18030"%><%...
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="GB18030"%>
<%@ page import="java.util.*" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>登录页面</title>
<script type="text/javascript">
function check(form)
{if (form.username.value=="")
{
alert("请输入用户名!!!");
form.username.focus();
return false;
}
if (form.password.value=="")
{
alert("请输入密码!!!");
form.password.focus();
return false;
}
}
</SCRIPT>
</head>
<body>
<form name="loginForm" method="post" action="judge.jsp" onsubmit="return check(this);" >
<table>
<tr>
<td>用户名:<input type="text" name="username" id="userName">10071130</td>
</tr>
<tr>
<td>密码:<input type="password" name="password" id="password">10071130</td>
</tr>
<tr>
<td><input type="submit" value="登录" style="background-color:pink" >
<input type="reset" value="重置" style="background-color:red"></td>
</tr>
</table>
</form>
</body>
</html>
单击后直接跳转到judge.jsp,为什么?求解 展开
<%@ page import="java.util.*" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>登录页面</title>
<script type="text/javascript">
function check(form)
{if (form.username.value=="")
{
alert("请输入用户名!!!");
form.username.focus();
return false;
}
if (form.password.value=="")
{
alert("请输入密码!!!");
form.password.focus();
return false;
}
}
</SCRIPT>
</head>
<body>
<form name="loginForm" method="post" action="judge.jsp" onsubmit="return check(this);" >
<table>
<tr>
<td>用户名:<input type="text" name="username" id="userName">10071130</td>
</tr>
<tr>
<td>密码:<input type="password" name="password" id="password">10071130</td>
</tr>
<tr>
<td><input type="submit" value="登录" style="background-color:pink" >
<input type="reset" value="重置" style="background-color:red"></td>
</tr>
</table>
</form>
</body>
</html>
单击后直接跳转到judge.jsp,为什么?求解 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询