说具体点。
这里有篇文章可以供你参考。
http://tech.ccidnet.com/pub/article/c1077_a170353_p1.html
http://tech.ccidnet.com/pub/article/c322_a173747_p1.html

解决方案 »

  1.   

    在Struts 1.1中也支持JavaScript客户端验证。如果你选择了客户端验证,当某个表单被提交以后,Struts 1.1启动客户端验证,如果浏览器不支持JavaScript验证,则服务器端验证被启动,这种双重验证机制能够最大限度地满足各种开发者的需要。JavaScript验证代码也是在validator-rules.xml文件中定义的。要启动客户端验证,你必须在相应的JSP文件中做如下设置:
    为<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中定义的基本验证功能不能满足你的需求,你可以自己添加所需的验证类型
      

  2.   

    有新问题阿,我用style="display=none"隐藏的text,struts没有验证阿,是不是struts的bug??
      

  3.   

    只能是你写的有问题,或者javascript没做判断,或者判断永真
      

  4.   

    晕,你试过了没有。我按 lijunjiejava(不眠之夜)一样做的,其他页面都可以验证。
    就是有style="display=none"的页面不行,我页面元素比较多所以用table分区来显示,隐藏的
      

  5.   

    http://www.cnpoint.com/MenuAction.do?action=main
      

  6.   

    好像隐藏的字段不能得到验证.
    因为struts的javascript函数校验的时候如果发现不符合要求便会把焦点转移到所验证的控件上,如果此控件为隐藏的,则会失败.
      

  7.   

    就是阿,老大你也碰到了,真是郁闷阿,又得用javascript