//jsp页面
function fnc_Check(){
    var form = document.MyForm;
    if(validateMyForm(form)){      document.MyForm.submit();
    }
   }

解决方案 »

  1.   

    [急??]我问的就是Struts中的Validator自动生成javascript代码一部分不能被调用,这是哪里引起的,怎么解决?谢谢。我用的struts1.1 Validator是1.0
      

  2.   

    也就是Struts中的Validator在jsp页面自动生成javascript代码一部分不能被调用???????????
      

  3.   

    记得action的form要对应好jsp页面
    <html:form action="deptMaintAction.do?method=save" onsubmit="return validateDeptForm(this);" >
    <html:hidden property="dept.id"/>
    <table width="100%" border="0" cellspacing="1" cellpadding="2"
    class="rightd">
    <tr>
    <td colspan="2" class="tdtitle">新建/编辑<bean:message key="dept.label"/></td>
    </tr>
    <tr>
    <td width="111" align="right" class="tdbgcolor1"><bean:message key="dept.bmmc"/></td>
    <td align="left" class="tdbgcolor1"><html:text property="dept.bmmc" ></html:text>
    </tr>

    <tr>
    <td align="right" class="tdbgcolor2"><bean:message key="dept.bh"/></td>
    <td align="left" class="tdbgcolor2"><html:text property="dept.bh"/></td>
    </tr>
            <tr>
                <td align="right" class="tdbgcolor1"><bean:message key="dept.zi"/></td>
                <td align="left" class="tdbgcolor1"><html:text property="dept.zi"/></td>
            </tr>
           
           
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td height="30" align="center"><input type="submit" name="Submit"
    value="确定" class="mybutton" /> &nbsp;&nbsp;&nbsp; <input
    type="submit" name="Submit2" value="返回" class="mybutton" /></td>
    </tr>
    </table>
    </html:form><html:javascript formName="DeptForm"
            dynamicJavascript="true"
             staticJavascript="false" />
     
    validator.xml<form name="DeptForm">
         <field 
           property="dept.bmmc" 
           depends="required">
          <arg0 key="dept.bmmc"/>
          </field >
          <field  
          property="dept.bh" 
          depends="required,maxlength">
          <arg0 key="dept.bh"/>
          <arg1 key="${var:maxlength}" resource="false" />
                <var>
                    <var-name>maxlength</var-name>
                    <var-value>2</var-value>
                </var>
          </field>
          </form>
      

  4.   

    前台验证如下:
    在<head>之间加上<html:javascript formName="cgsqdForm1" method="validate"/>然后,<html:form action="/cgsqdModAction" onsubmit="return validate(this)" >
      

  5.   

    我的struts是1.1Validator是1.0,为什么生成的脚本中没有生成validate()方法或类似alidateDeptForm(this)的方法,需要如何配置配置文件!