急,急,急,請教高手struts驗證的問題!

tony_2008發表於2003-06-13
我的jsp檔案如下:
<html:form action="/oa/fawen" focus="wenjianbiaoti" onsubmit="return validateFawenForm(this);">
</html:form>
<html:javascript formName="fawenForm"
dynamicJavascript="true"
staticJavascript="false"/>
<script language="Javascript1.1" src="staticJavascript.jsp"></script>

validator.xml檔案中的片斷如下:
<form name="fawenForm">
<field property="wenjianbiaoti" depends="required,minlength,maxlength">
<arg0 key="fawenForm.wenjianbiaoti"/>
<arg1 key="${var:minlength}" name="minlength" resource="false"/>
<arg2 key="${var:maxlength}" name="maxlength" resource="false"/>
<var>
<var-name>maxlength</var-name>
<var-value>20</var-value>
</var>
<var>
<var-name>minlength</var-name>
<var-value>6</var-value>
</var>
</field>
</form>

struts-config.xml檔案中的片斷如下:
<form-bean name="fawenForm" type="com.eway.oa.fawen.FawenForm"/>
<action-mappings>
<action input="fawen" name="fawenForm" path="/oa/fawen" scope="request"
type="com.eway.oa.fawen.FawenAction" validate="true">
<forward name="success" path="/oa/fawen/fawen.jsp" redirect="false"/>
</action>
</action-mappings>
jsp檔案執行後已經生成了驗證的指令碼,生成的HTML程式碼如下:
<form name="fawenForm" method="post" action="/oa/fawen.do" onsubmit="return validateFawenForm(this);">
</form>
<script type="text/javascript" language="JavaScript">
<!--
var focusControl = document.forms["fawenForm"].elements["wenjianbiaoti"];

if (focusControl.type != "hidden") {
focusControl.focus();
}
// -->
</script>

<script type="text/javascript" language="Javascript1.1">

<!-- Begin

var bCancel = false;

function validateFawenForm(form) {
if (bCancel)
return true;
else
return validateMaxLength(form) && validateMinLength(form) && validateRequired(form);
}

function maxlength () {
this.aa = new Array("wenjianbiaoti", " cannot be greater than 20 characters.", new Function ("varName", "this.maxlength='20'; this.minlength='6'; return this[varName];"));
}

function minlength () {
this.aa = new Array("wenjianbiaoti", " cannot be less than 6 characters.", new Function ("varName", "this.maxlength='20'; this.minlength='6'; return this[varName];"));
}

function required () {
this.aa = new Array("wenjianbiaoti", " is required.", new Function ("varName", "this.maxlength='20'; this.minlength='6'; return this[varName];"));
}


//End -->
</script>

但是此指令碼卻不執行!請問高手這是怎麼回事?

相關文章