I don't know the exact code (I always forget JS details) but the basic
idea would be to give your checkboxes IDs in the JSP, then use
getElementById() to grab the DOM nodes for them and just do
(node.checked == true), then && the results. And your submit would have
call the method that validates as its onClick event and only submits the
form if the validation passes.

JavaScript is ubiquitous enough that Google has plenty of results for
it, so have a look:
http://www.google.com/search?q=javascript+checkbox+group&btnG=z34r%3C%7C
-%7C Hopefully that ought to point you in the right direction.

~DVA



-----Original Message-----
From: mojoRising [mailto:[EMAIL PROTECTED] 
Sent: Friday, May 09, 2008 2:34 PM
To: user@struts.apache.org
Subject: RE: How to validate a checkboxlist?


I am using struts 2.0.11, and with the validation framework, client-side
validation is of course done using javascript:
http://struts.apache.org/2.x/docs/client-validation.html


Javascript must be used for my project so I have no problem requiring
it.
The client side (javascript)validation works perfectly for text
boxes...but
I don't see how to make it check that a checkboxlist has at least one
box
checked? Has anyone ever done this?




Allen, Daniel wrote:
> 
> If you want client-side anything, wouldn't you want to use JavaScript?
> As far as I know, everything XWork validation does is on the server.
> 
> (I would say have a validator in the action bean too, though, in case
> the use has JS disabled and manages to submit without passing that
> check.)
> 
> -----Original Message-----
> From: mojoRising [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, May 08, 2008 5:21 PM
> To: user@struts.apache.org
> Subject: How to validate a checkboxlist?
> 
> 
> I am trying to perform client side validation on a struts checkboxlist
> tag
> but nothing I try seems to work.  ANy ideas? I do not want to submit
the
> form and do a validation method in the action bean because obviously
it
> would be ridiculous to post back to the server just to check that
there
> is
> at least one checkbox selected....
> 
> This is what I have:  
> 
> 
> <s:checkboxlist  label="Assigned Roles"  title="Assigned Roles"
>                        name="selectedRoles"
>                        value="selectedRoles"
>                        listValue="value"
>                        listKey="id" 
>                        list="roleList"
>                        required="true"/>
> 
> 
> <!DOCTYPE validators PUBLIC
>         "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
>         "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd";>
> 
> <validators>
>       <field name="selectedRoles">
>         <field-validator type="required">
>                  <message>You must select at least one role for this
> user</message>
>         </field-validator>
>     </field>
> </validators>
> -- 
> View this message in context:
>
http://www.nabble.com/How-to-validate-a-checkboxlist--tp17136631p1713663
> 1.html
> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> -- 
> This message may contain confidential, proprietary, or legally
privileged
> information. No confidentiality or privilege is waived by any
transmission
> to an unintended recipient. If you are not an intended recipient,
please
> notify the sender and delete this message immediately. Any views
expressed
> in this message are those of the sender, not those of any entity
within
> the KBC Financial Products group of companies (together referred to as
> "KBC FP"). 
> 
> This message does not create any obligation, contractual or otherwise,
on
> the part of KBC FP. It is not an offer (or solicitation of an offer)
of,
> or a recommendation to buy or sell, any financial product. Any prices
or
> other values included in this message are indicative only, and do not
> necessarily represent current market prices, prices at which KBC FP
would
> enter into a transaction, or prices at which similar transactions may
be
> carried on KBC FP's own books. The information contained in this
message
> is provided "as is", without representations or warranties, express or
> implied, of any kind. Past performance is not indicative of future
> returns.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context:
http://www.nabble.com/How-to-validate-a-checkboxlist--tp17136631p1715411
0.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


-- 
This message may contain confidential, proprietary, or legally privileged 
information. No confidentiality or privilege is waived by any transmission to 
an unintended recipient. If you are not an intended recipient, please notify 
the sender and delete this message immediately. Any views expressed in this 
message are those of the sender, not those of any entity within the KBC 
Financial Products group of companies (together referred to as "KBC FP"). 

This message does not create any obligation, contractual or otherwise, on the 
part of KBC FP. It is not an offer (or solicitation of an offer) of, or a 
recommendation to buy or sell, any financial product. Any prices or other 
values included in this message are indicative only, and do not necessarily 
represent current market prices, prices at which KBC FP would enter into a 
transaction, or prices at which similar transactions may be carried on KBC FP's 
own books. The information contained in this message is provided "as is", 
without representations or warranties, express or implied, of any kind. Past 
performance is not indicative of future returns.


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

Reply via email to