struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From orshoe <ors...@yahoo.com>
Subject Struts 2 Validation multiple validators on same field
Date Tue, 07 Aug 2007 21:25:52 GMT

Hi all,
I am trying to enforce a "requiredstring" on a text field and also make sure
it follows certain constraints. I am using the following in the
<action>-validation.xml:
---------------------------------------------------------------------------------------------------------------------------
<validators>
    <field name="accountNumber">
        <field-validator type="int">
	          <para m nam e="min">6</para m>
	          <para m nam e="max">10</para m>
            <message>Account Number cannot be less than ${min} or greater
than ${max}. Its currently ${accountNumber}</message>
        </field-validator>
    </field>
    <field name="accountNumber">
        <field-validator type="requiredstring">
            <message>You must enter Account Number</message>
        </field-validator>
    </field>
</validators>
---------------------------------------------------------------------------------------------------------------------------
The problem is, I am getting both the messages displayed (also the "You must
enter Account Number") even when there is a value (say, 5) entered in the
field. Is there any way to get only the appropriate message displayed based
on the input.
note: Please ignore the extra spaces in the param tags, I had intentionally
added the space to make sure the message preview'd properly.
-- 
View this message in context: http://www.nabble.com/Struts-2-Validation-multiple-validators-on-same-field-tf4232748.html#a12042474
Sent from the Struts - User mailing list archive at Nabble.com.


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


Mime
View raw message