You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chetan Pandey <cp...@BLUEsingapore.com> on 2006/08/21 12:43:11 UTC

Validation

I have a field in my form for which I am doing the following validation.

Basically it has to be exactly 5 characters long.

The following works.

    <field
                property="propertyVO.holidexCode" depends="minlength">
                <arg0 key="lms.holidexCode"/>
                <arg1 name="minlength" key="${var:minlength}"
resource="false"/>
 
<var><var-name>minlength</var-name><var-value>5</var-value></var>
          </field>
          
           <field
                property="propertyVO.holidexCode" depends="maxlength">
                <arg0 key="lms.holidexCode"/>
                <arg1 name="maxlength" key="${var:maxlength}"
resource="false"/>
 
<var><var-name>maxlength</var-name><var-value>5</var-value></var>
          </field>

However, I want a message like "{0} only takes 5 characters"

I cannot change errors.minlength/maxlength as I may want to use them as they
come by default for other validations in future.

Is their a way I can override the default messages for these two..

Thanks.

CHetan




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Validation

Posted by Rimzim Sinha <ri...@yahoo.com>.
Use this
   
     <form name="formname">
         <field property="employerIdentificationNumber" depends="minlength">
          <arg0 key="formname.employerIdentificationNumber"/>
          <msg name="minlength" key="welcomeForm.employerIdentificationNumber.required" resource="true"/>
         </field>
            </form>
   
  And add to message.properties
   
   
  #formname.employerIdentificationNumber.required={0} - Please enter. Employer ID Number is required.

        

Chetan Pandey <cp...@BLUEsingapore.com> wrote:
  I have a field in my form for which I am doing the following validation.

Basically it has to be exactly 5 characters long.

The following works.

property="propertyVO.holidexCode" depends="minlength">

resource="false"/>

minlength5


property="propertyVO.holidexCode" depends="maxlength">

resource="false"/>

maxlength5


However, I want a message like "{0} only takes 5 characters"

I cannot change errors.minlength/maxlength as I may want to use them as they
come by default for other validations in future.

Is their a way I can override the default messages for these two..

Thanks.

CHetan




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



 		
---------------------------------
How low will we go? Check out Yahoo! Messenger’s low  PC-to-Phone call rates.