Hi

I am having problem with this, in CakePHP it outputs the thml for a
checkbox as the following:

<div class="input checkbox">
<input id="CoverAgreed_" type="hidden" value="0" name="data[Cover]
[agreed]"/>
<input id="CoverAgreed" class="" type="checkbox" value="1"
name="data[Cover][agreed]"/>
<label for="CoverAgreed">do you agree to the terms?</label>
</div>

I have been unbale to get a validation to ensure the checkbox is
checked .

Here is my option code:
        $("#CoverAddForm").validate({
                                                ignore: "[EMAIL PROTECTED]" ,
                                                rules: {
'data[Cover][agreed]': {
                                        required: true

                                }
}

I am very new to jQuery and this plugin, so I realise I am probably
missing something simple!

the problem is that CakePHP checkbox creates 2 checkboxes, with same
name, but different ID. I realise it is not possible to use the ID in
Validate plugin.

thank you for a great plug-in by the way,

Luke


On Oct 10, 12:07 pm, "Weyert de Boer" <[EMAIL PROTECTED]> wrote:
> Hmm, I will give it a try. I am currently hiding the container element
> of the form fields.  I suppose this means I would need to write a
> custom method for hiding/showing which adds this class name and add it
> to the actual form field element too.
>
> On Fri, Oct 10, 2008 at 1:42 PM, Jörn Zaefferer
>
> <[EMAIL PROTECTED]> wrote:
> > You use theignore-option (a selector) to set additional elements to
> >ignorewhen validating. One approach would be to define a class in
> > your stylesheet with display:none, then adding and removing that class
> > to hide an element, and set the optionignore:
> > ".customClassHidingElements".
>
> > Jörn
>
> > On Fri, Oct 10, 2008 at 12:23 PM, Weyert de Boer <[EMAIL PROTECTED]> wrote:
>
> >> Hello!
>
> >> I am currently hiding or showing specific form fields depending on
> >> specific conditions. Only if the field is hidden they are still used
> >> tovalidateagainst when submitting the form. Are there any ways to
> >>ignoreany field validations when the element is hidden? Because when
> >> the field is hidden it doesn't have to be filled in.
>
> >> Any way to solve this? I am currently using code like this:
>
> >> $("#question_2").click(function() {
> >>   var itemValue = $("#question_2").val();
> >>   var toggleItems =
> >> $("#field-question_11,#field-question_12,#field-question_13");
> >>   var condition = eval("itemValue == 'd'");
> >>   if ( condition ) { toggleItems.show() } else { toggleItems.hide() };
> >> });
>
> >> Yours,
> >> Weyert de Boer

Reply via email to