Hi, 

(should've posted this message on 'commons' to get more answers, ah well, hope
there is enough talents in this pool to grind my petty problem into the dust).

As the title suggested, somehow my validator is trying to validate the
'minlength' of every single field no matter whether I set depends="required" or
not.  It seems that all the empty fields are submited by the browser.  Based on
what's stated in validator documentation:  since browser will not submit empty
fields, any field that isn't required will skip all validations if the fields is
null or has a length of zero.  But my browser is doing the exact opposite.  Here
is my form:

<form name="ManageForm" method="post"
action="/Manage.do;jsessionid=26CB107EF9925FB8EEDD4F1223FD89D9"
enctype="multipart/form-data">
<input type="text" name="hInput" value="">
<input type="submit" value="submit" >
</form>

-- in validation.xml --
   <formset>
      <!-- Forms -->
      <form name="ManageTranslateForm">
         <field property="hInput"
             depends="minlength">
               <arg0 key="hInput.displayname"/>
                   <arg1 name="minlength" key="${var:minlength}"
resource="false"/>
                     <var>
                       <var-name>minlength</var-name>
                       <var-value>6</var-value>
                     </var>
         </field>
      </form>
    </formset>

-- in validator-rules.xml --
      <validator name="minlength"
            classname="org.apache.struts.validator.FieldChecks"
               method="validateMinLength"
         methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionErrors,
                       javax.servlet.http.HttpServletRequest"
              depends=""
                  msg="errors.minlength">

I don't know how required() could be invoked when it's not set on this
particular field.  Also if browser do sumbit empty fields, then something is
wrong with the 'required' validator.  But the fact that I have used the
validator successfully before contradicts that conclusion.  But it's kind of
vague in w3 recommendation on whether or not the browser should support this
behaviour:
        If a control doesn't have a current value when the form is submitted,
user agents are not required to treat it as a successful control. 

Any idea greatly appreciated!

-Yan


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to