<%@ page language="java" contentType="text/html; charset=gb2312"
pageEncoding="gb2312"%>
<%@ page import="com.user.UserBean"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>登陆页面</title>
<script type="text/javascript" language="JavaScript">
function Check() {
var username = document.getElementById("username");
var password = document.getElementById("password");
if (username.Value == "") {
alert("用户名不能为空!");
return false;
} else if (password.Value == "") {
alert("密码不能为空!");
return false;
}
}
</script>
</head>
<body> <center>
<h1>欢迎来到原创教务系统</h1>
</center>
<form action="LoginAction.do" method="post" onSubmit="return Check();">
<table width="298" border="1" align="center" cellpading="4"
cellspacing="1">
<tr>
<td width="20%" align="left">用户类型 :</td>
<td width="80%"><select name="userKind">
<option value="student">学生</option>
<option value="teacher">教师</option>
</select></td>
</tr>
<tr>
<td width="20%" align="left">用 户 名:</td>
<td><input width="80%" type="text" name="username"
id="username" size="15"
></td>
</tr>
<tr>
<td width="20%" align="left">密 码:</td>
<td><input width="80%" type="password" name="password"
id="password" size="15"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="登录">
</tr>
</table>
</form>
</body>
</html>
为什么在这里无法执行javascript脚本语句,在onSubmit="return Check()"这句这里提示Cannot return from outside a function or method.,该怎样去修改?????
pageEncoding="gb2312"%>
<%@ page import="com.user.UserBean"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>登陆页面</title>
<script type="text/javascript" language="JavaScript">
function Check() {
var username = document.getElementById("username");
var password = document.getElementById("password");
if (username.Value == "") {
alert("用户名不能为空!");
return false;
} else if (password.Value == "") {
alert("密码不能为空!");
return false;
}
}
</script>
</head>
<body> <center>
<h1>欢迎来到原创教务系统</h1>
</center>
<form action="LoginAction.do" method="post" onSubmit="return Check();">
<table width="298" border="1" align="center" cellpading="4"
cellspacing="1">
<tr>
<td width="20%" align="left">用户类型 :</td>
<td width="80%"><select name="userKind">
<option value="student">学生</option>
<option value="teacher">教师</option>
</select></td>
</tr>
<tr>
<td width="20%" align="left">用 户 名:</td>
<td><input width="80%" type="text" name="username"
id="username" size="15"
></td>
</tr>
<tr>
<td width="20%" align="left">密 码:</td>
<td><input width="80%" type="password" name="password"
id="password" size="15"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="登录">
</tr>
</table>
</form>
</body>
</html>
为什么在这里无法执行javascript脚本语句,在onSubmit="return Check()"这句这里提示Cannot return from outside a function or method.,该怎样去修改?????
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>登陆页面</title>
<script type="text/javascript" language="JavaScript">
function Check() {
var username = document.getElementById("username");
var password = document.getElementById("password");
if (username.value == "") {
alert("用户名不能为空!");
return false;
}
if (password.value == "") {
alert("密码不能为空!");
return false;
}
}
</script>
</head>
<body><center>
<h1>欢迎来到原创教务系统</h1>
</center>
<form action="LoginAction.do" method="post" onSubmit="return Check();">
<table width="298" border="1" align="center" cellpading="4" cellspacing="1">
<tr>
<td width="20%" align="left">用户类型 :</td>
<td width="80%"><select name="userKind">
<option value="student">学生</option>
<option value="teacher">教师</option>
</select></td>
</tr>
<tr>
<td width="20%" align="left">用 户 名:</td>
<td><input width="80%" type="text" name="username" id="username" size="15"></td>
</tr>
<tr>
<td width="20%" align="left">密 码:</td>
<td><input width="80%" type="password" name="password" id="password" size="15"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="登录">
</tr>
</table>
</form>
</body>
</html>