日期:2014-05-17  浏览次数:20687 次

拜求解:关于jsp中的form的onsubmit
<%@ page language="java" pageEncoding="gbk"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>登录……系统</title>
<link href="css/css.css" rel="stylesheet" type="text/css" />
<script src="js/checkform.js" language="<JavaScript" type="text/javascript"></script>
</head>

<body>
<div class="idiv1">
  <form id="form1" onsubmit="return checkselect(this);" method="post" action="servlet/Login">
  <h3>登录</h3>
  <p class="p1">用户名:<input name="name" type="text" /> <font color="#FF0000"> *</font></p>
  <p class="p1">密码:<input name="password" type="password" /> <font color="#FF0000"> *</font></p>
  <p class="p1"><input value="用户登录" type="submit"/> &nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="重置"/></p>
  <p class="p1"><a href="">注册</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="">忘记密码</a>
  </form>
</div>
</body>
</html>

js/checkform.js为:
function checkselect(object) {
if (object.name.vale=="") {
alert("用户名不能为空!");
 
return false;
} else if (object.password.value=="") {
alert("密码不能为空!")

return false;
} else {
return true;
}

}

为什么不会有提示…………………………………………………………





------解决方案--------------------
language="<JavaScript" 多了个<

试过了可以提示啊
------解决方案--------------------
if (object.name.vale=="") {
alert("用户名不能为空!");
这里少了个U