You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Schneider <Da...@thestreet.com> on 2004/10/25 18:12:12 UTC
requiredif combined with other validation rules
hi. i'm using struts 1.1 and have a question about combining requiredif
with other validation rules. i have
<field property="zip" depends="requiredif, mask">
<msg name="requiredif" key="CustomerInfoForm.zip.invalid"/>
<msg name="mask" key="CustomerInfoForm.zip.invalid"/>
<var>
<var-name>field[0]</var-name>
<var-value>country</var-value>
</var>
<var>
<var-name>fieldTest[0]</var-name>
<var-value>EQUAL</var-value>
</var>
<var>
<var-name>fieldValue[0]</var-name>
<var-value>840</var-value>
</var>
<var>
<var-name>mask</var-name>
<var-value>${uszipmask}</var-value>
</var>
<field>
if a user chooses a country other than 840 (usa) and leaves the zip blank,
then the form passes validation. however, if he chooses a country other
than 840 and enters something in the zip field then the mask is applied to
that value. i would like the mask rule to be bypassed also if the country
isn't 840. is this possible?
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: requiredif combined with other validation rules
Posted by Adam Hardy <ah...@cyberspaceroad.com>.
I don't think that's surprising behaviour. It sounds like what you
really need is a 'maskIf' test. You could possibly roll your own from
the requiredif and mask.
On 10/25/2004 05:12 PM David Schneider wrote:
> hi. i'm using struts 1.1 and have a question about combining requiredif
> with other validation rules. i have
>
> <field property="zip" depends="requiredif, mask">
> <msg name="requiredif" key="CustomerInfoForm.zip.invalid"/>
> <msg name="mask" key="CustomerInfoForm.zip.invalid"/>
> <var>
> <var-name>field[0]</var-name>
> <var-value>country</var-value>
> </var>
> <var>
> <var-name>fieldTest[0]</var-name>
> <var-value>EQUAL</var-value>
> </var>
> <var>
> <var-name>fieldValue[0]</var-name>
> <var-value>840</var-value>
> </var>
> <var>
> <var-name>mask</var-name>
> <var-value>${uszipmask}</var-value>
> </var>
> <field>
>
> if a user chooses a country other than 840 (usa) and leaves the zip blank,
> then the form passes validation. however, if he chooses a country other
> than 840 and enters something in the zip field then the mask is applied to
> that value. i would like the mask rule to be bypassed also if the country
> isn't 840. is this possible?
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org