More googling I did find a solution to my problem. In essential, I
RTFM. Here is the blurb from
http://tetlaw.id.au/view/javascript/really-easy-field-validation
"*To use the validate-one-required validator you must first add the
class name to only one checkbox/radio button in the group (last one is
probably best) and then place all the input elements within a parent
element, for example a div element. That way the library can find all
the checkboxes/radio buttons to check and place the validation advice
element at the bottom of the parent element to make it appear after
the group of checkboxes/radio buttons."
<div id="strategies">
<?brail
items = FormHelper.CreateCheckboxList("project.strategies",
strategies, { @value: 'Id', @text: 'Name' })
for item in items:
output items.Item()
output item.Name
?>
<br />
<?brail end ?>
<input type="hidden" class="validate-one-required" />
</div>
I placed the hidden input so that I didn't have to figure out how to
place the class on the last checkbox in my list.
Jason
On Oct 29, 2:28 pm, jsmorris <[EMAIL PROTECTED]> wrote:
> I was hoping that there might be a MR solution to this without the
> need to pull in jQuery.
>
> I googled and found the jQuery Validation plugin and it does seem very
> straight forward.
>
> On Oct 29, 12:39 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > This isn't built into MR (that I know of) but I've been using the
> > jQuery Validation plugin lately. It's super simple, you just add
> > classes to the elements you want to validate.
>
> > i.e. <input type="text" class="required email"/>
>
> > I know that is a little against the whole DRY principal but it works
> > well.
>
> > On Oct 29, 2:16 pm, jsmorris <[EMAIL PROTECTED]> wrote:
>
> > > In my new view, I have
>
> > > <?brail
> > > items = FormHelper.CreateCheckboxList("project.strategies",
> > > strategies, { @value: 'Id', @text: 'Name' })
> > > for item in items:
> > > output items.Item()
> > > output item.Name
> > > ?>
>
> > > to create a list of checkboxes.
>
> > > I want to enforce that the user has to select at least one of the
> > > checkboxes from the list.
>
> > > I saw in the FormHelper javascript, there is validation for validate-
> > > one-required, so I tried to add that as a class on each checkbox, but
> > > as you tab through the checkboxes, I get the validation error message
> > > repeated under my list of checkboxes, like so.
>
> > > Please select one of the above options.
> > > Please select one of the above options.
> > > Please select one of the above options.
> > > Please select one of the above options.
>
> > > I also have my Project model with marked with
> > > ValidateCollectionNotEmpty.
>
> > > What is the best way to get client side validation so that at least
> > > one checkbox in the list is selected?
>
> > > Thanks,
> > > Jason
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---