说具体点。
这里有篇文章可以供你参考。
http://tech.ccidnet.com/pub/article/c1077_a170353_p1.html
http://tech.ccidnet.com/pub/article/c322_a173747_p1.html
这里有篇文章可以供你参考。
http://tech.ccidnet.com/pub/article/c1077_a170353_p1.html
http://tech.ccidnet.com/pub/article/c322_a173747_p1.html
为<html:form>增加onsubmit属性
设置Javascript支持 下表中列出了一JSP文件的示例代码,红字部分为Javascript验证所需代码。
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<table bgcolor="#9AFF9A" cellspacing="0" cellpadding="10" border="1" width="100%">
<tr>
<td>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr bgcolor="#696969">
<td align="center">
<font color="#FFFFFF">Panel 3: Profile</font>
</td>
</tr>
<tr>
<td><br>
<html:errors/>
<html:form action="/login.do" focus="username" onsubmit="return validateLoginForm(this);">
<html:hidden property="actionClass"/>
<center>
<table>
<tr>
<td>UserName:</td>
<td><html:text property="username" size="20"/></td>
</tr>
<tr>
<td>Password:</td>
<td><html:password property="password" size="20"/></td>
</tr>
<tr>
<td colspan=2><html:submit property="submitProperty" value="Submit"/></td>
</table>
</center>
</html:form>
<html:javascript formName="loginForm" dynamicJavascript="true" staticJavascript="false"/>
<script language="Javascript1.1" src="staticJavascript.jsp"></script>
</td>
</tr>
</table>
</td>
</tr>
</table> 其中onsubmit的值为"return validateLoginForm(this);",它的语法为:return validate + struts-config.xml中定义的form-bean名称 + (this);staticJavascript.jsp的内容为:
<%@ page language="java" %>
<%-- set document type to Javascript (addresses a bug in Netscape according to a web resource --%>
<%@ page contentType="application/x-javascript" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html:javascript dynamicJavascript="false" staticJavascript="true"/> 如果validator-rules.xml中定义的基本验证功能不能满足你的需求,你可以自己添加所需的验证类型
就是有style="display=none"的页面不行,我页面元素比较多所以用table分区来显示,隐藏的
因为struts的javascript函数校验的时候如果发现不符合要求便会把焦点转移到所验证的控件上,如果此控件为隐藏的,则会失败.