读书人

在JSP中使用JS表单验证的有关问题

发布时间: 2013-09-11 17:59:59 作者: rapoo

在JSP中使用JS表单验证的问题
我在一个JSP页面中想用JS进行表单验证的时候出错了,能否帮我看一下啊。是一个使用STRUTS标签的JSP页面。本人是新学的,所以可能会出现些很低级的错误,请帮帮忙了

<%@ page language= "java " pageEncoding= "GBK "%>
<%@ taglib uri= "http://jakarta.apache.org/struts/tags-bean " prefix= "bean "%>
<%@ taglib uri= "http://jakarta.apache.org/struts/tags-html " prefix= "html "%>

<html>
<head>
<title> 用户登陆 </title>

<script language= "javascript ">
function checkForm(){
if(document.userlogin.id.value== " ")
{
alert( "请输入身份证号码! ");
document.userlogin.id.focus();
return false;
}
return true;
}
</script>
</head>
<body>
<html:form action= "/login " method= "post " onsubmit= "return checkForm() " name= "userlogin ">
<table border= "2 " align= "center " bordercolor= "#000000 " bgcolor= "#99CCCC ">
<tr>
<td> 身  份: </td>
<td colspan= "2 ">
<html:select property= "sf ">
<html:option key= "----主管---- " value= "主管 " />
<html:option key= "----老师---- " value= "教师 " />
<html:option key= "----同学---- " value= "学生 " />
</html:select>
</td>
</tr>
<tr>
<td> 身份证号: </td>
<td colspan= "2 "> <html:text property= "id "/> </td>
</tr>
<tr>
<td> 密  码: </td>
<td colspan= "2 "> <html:password property= "psw "/> <br> </td>
</tr>
<tr>
<td> 验证码: </td>
<td> <html:text property= "randCode " size= "5 "/> <br> </td>
<!-- <td> <img alt= "看不清楚? " src= "imgcode " onClick= "this.src= 'imgcode ' "/>
</td> -->
</tr>
<tr>
<td align= "center " colspan= "3 "> <html:submit value= "提交 "/>
    
<html:reset value= "取消 "/> </td>
</tr>
</table>
</html:form>
</body>
</html>

**************************出错提示**************************

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception



org.apache.jasper.JasperException: /login.jsp(22,2) Attribute name invalid for tag form according to TLD
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)

[解决办法]
function checkForm(){
if(document.all( "id ").value== " ")
{
alert( "请输入身份证号码! ");
document.all( "id ").focus();
return false;
}
return true;
}

我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html

读书人网 >Java Web开发

热点推荐