Discussions

Web tier: servlets, JSP, Web frameworks: Conditiional validation using Validator Frame Work in struts..??

  1. Hi,

      I have a form to submit and there are some propertis which must be checked at one condition and are must not be checked for another condition.


       How should I do it..


    Thanx in advance

    MaRu
    :)
  2. Try using <requiredif> tag in your validation.xml. An example is as follows:

    <field property="ccID" depends="requiredif,mask">
    <arg0 key="form.creditcard.cid"/>
    <msg name="mask" key="errors.ccid.invalid"/>
    <var>
    <var-name>mask</var-name>
    <var-value>^[0-9]*$</var-value>
    </var>
    <var>
    <var-name>field[0]</var-name>
    <var-value>ccNoID</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>off</var-value>
    </var>
    </field>
  3. Which version of struts is available on using the requiredif validation?