Just use the "required" validator.

 <field property="terms" depends="required">
        <arg key="requestaccount.terms.displayname"/>
  </field>


Niall

----- Original Message ----- 
From: "Scott Purcell" <[EMAIL PROTECTED]>
To: <user@struts.apache.org>
Sent: Wednesday, March 16, 2005 4:18 PM
Subject: Checkbox Validation Help Needed


I am working on a project where I have the need to validate a checkbox being
'on' . It is the usual accept our license, or you cannot enter site. In the
jsp page we are using this:
<tr><td colspan=4><br><html:checkbox property="terms" value="0"/>

And in my bean I have a getter and setter with a boolean value:
eg:
setTerms(boolean val)
boolean getTerms()

and in my validation.xml I have this:
 <field property="terms" depends="validwhen">
        <arg key="requestaccount.terms.displayname"/>
        <var>
          <var-name>test</var-name>
          <var-value>(*this* != null)</var-value>
        </var>
    </field>

But, if the user does not check this checkbox, the validator does not seem
to catch it?

Can anyone give me some advice here?

Thanks,

Scott



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to