首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

用javascript验证信息时出现了这个异常

2012-02-19 
用javascript验证信息时出现了这个错误我想用javascript验证提交的username和userpassword信息,但是编译时

用javascript验证信息时出现了这个错误
我想用javascript验证提交的username和userpassword信息,但是编译时出现
org.apache.jasper.JasperException:   /reg.jsp(29,1)   Attribute   name   invalid   for   tag   form   according   to   TLD
我想是不是 <html:form   method= "post "   name= "reg "   language= "javascript "   action= "/reg "   onsubmit= "return   Check(); "> 这里写错了,或者还有其他的错误,请各位大虾指点一下小弟,谢谢


<%@   page   language= "java "%>
<%@   page   contentType= "text/html;   charset=gb2312 "%>

<%@   taglib   uri= "http://struts.apache.org/tags-bean "   prefix= "bean "%>
<%@   taglib   uri= "http://struts.apache.org/tags-html "   prefix= "html "%>
<%@   taglib   uri= "http://struts.apache.org/tags-logic "   prefix= "logic "%>
<%@   taglib   uri= "http://struts.apache.org/tags-tiles "   prefix= "tiles "%>


<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.01   Transitional//EN ">
<html:html   lang= "true ">
<head>
<html:base   />

<title> reg.jsp </title>

<meta   http-equiv= "pragma "   content= "no-cache ">
<meta   http-equiv= "cache-control "   content= "no-cache ">
<meta   http-equiv= "expires "   content= "0 ">
<meta   http-equiv= "keywords "   content= "keyword1,keyword2,keyword3 ">
<meta   http-equiv= "description "   content= "This   is   my   page ">
<!--
<link   rel= "stylesheet "   type= "text/css "   href= "styles.css ">
-->

</head>

<body>
<html:form   method= "post "   name= "reg "   language= "javascript "   action= "/reg "
onsubmit= "return   Check(); ">
<table   valign= "center ">
<tr>
<td>
用户名
</td>
<td>
<html:text   property= "username "   />
</td>
</tr>
<tr>
<td>
密码
</td>
<td>
<html:password   property= "userpassword "   />
</td>
</tr>
<tr>
<td>
性别
</td>
<td>
<html:radio   property= "sex "   value= "男 "> 男 </html:radio>
<html:radio   property= "sex "   value= "女 "> 女 </html:radio>
</td>
</tr>
<tr>
<td>
学历
</td>
<td>
<html:select   property= "education ">
<html:option   value= " "> </html:option>
<html:option   value= "高中 "> 高中 </html:option>
<html:option   value= "大学 "> 大学 </html:option>
<html:option   value= "研究生 "> 研究生 </html:option>
<html:option   value= "博士 "> 博士 </html:option>


</html:select>
</td>
</tr>
<tr>
<td>
<html:submit> 提交 </html:submit>
</td>
<td>
<html:reset> 重置 </html:reset>
</td>
</tr>
<script   language= "JavaScript ">
function   Check(){
if(document.reg.username.value== " "){
alert( "用户名非空! ")
document.reg.username.focus()
return   false
}
if(document.reg.userpassword.value== " "){
alert( "密码非空! ")
document.reg.userpassword.focus()
return   false
}
}
</script>
</table>
</html:form>
</body>
</html:html>


[解决办法]
把 <html:form method= "post " name= "reg " language= "javascript " action= "/reg " onsubmit= "return Check(); "> 句
的name= "reg "去掉,看看
[解决办法]
去掉language= "javascript "
[解决办法]
<html:form method= "post " name= "reg "action= "/reg ">

<script>
document.forms.reg.onsubmit = function()
{
return Check();
}
</script>

[解决办法]
document.reg.username.value 改成document.forms[0].username.value ,下面password也一样,

热点排行