You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Joseph Yang <ya...@rewardstream.com> on 2003/04/11 00:04:11 UTC
How to use Struts Validator to validate web element dependencies?
Hello all,
On the Jsp page, there are a checkbox(please contact me) and a text box (my
email address)
the text box will become required only if user check the checkbox
How should I handle this using Struts Validator?
Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: How to use Struts Validator to validate web element dependencies?
Posted by Jeff Kyser <kt...@comcast.net>.
Use the 'requiredif' rule. Here's an example of a form
with radio button for uploading information from a FormFile
OR a textarea, depending on which radio button is set.
See the validation docs for more info:
http://jakarta.apache.org/struts/userGuide/dev_validator.html
I'm using 1.1b3, so the variable names still use field-test,
field-value instead of the later (legal javascript names) fieldTest,
fieldValue.
HTH,
-jeff
<form name="uploadForm">
<field property="inputVia" depends="required">
<arg0 key="uploadForm.inputVia.errorname"/>
</field>
<field property="file.fileName" depends="requiredif">
<arg0 key="uploadForm.file.errorname"/>
<var>
<var-name>field[0]</var-name>
<var-value>inputVia</var-value>
</var>
<var>
<var-name>field-test[0]</var-name>
<var-value>EQUAL</var-value>
</var>
<var>
<var-name>field-value[0]</var-name>
<var-value>FILE_SELECT</var-value>
</var>
</field>
<field property="manualText" depends="requiredif">
<arg0 key="uploadForm.manualText.errorname"/>
<var>
<var-name>field[0]</var-name>
<var-value>inputVia</var-value>
</var>
<var>
<var-name>field-test[0]</var-name>
<var-value>EQUAL</var-value>
</var>
<var>
<var-name>field-value[0]</var-name>
<var-value>MANUAL_INPUT</var-value>
</var>
</field>
</form>
On Thursday, April 10, 2003, at 05:04 PM, Joseph Yang wrote:
> Hello all,
>
> On the Jsp page, there are a checkbox(please contact me) and a text
> box (my
> email address)
>
> the text box will become required only if user check the checkbox
>
> How should I handle this using Struts Validator?
>
> Thanks
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org