Carlos,

Thanks for your response for problem #2. I viewed the generated source
code using web developer addon-firefox. The <li> has class "valid"
instead of "error". So i guess you are right, the problem is with the
checkbox validation. I guess this is a bug with Jquery validation.

Here is the built-in code:

        check: function( element ) {
                        element = this.clean( element );

                        // if radio/checkbox, validate first element in group 
instead
                        if (this.checkable(element)) {
                                element = this.findByName( element.name )[0];
                        }

                        var rules = $(element).rules();
                        var dependencyMismatch = false;
                        for( method in rules ) {
                                var rule = { method: method, parameters: 
rules[method] };
                                try {
                                        var result = 
$.validator.methods[method].call( this,
element.value.replace(/\r/g, ""), element, rule.parameters );

                                        // if a method indicates that the field 
is optional and therefore
valid,
                                        // don't mark it as valid when there 
are no other rules
                                        if ( result == "dependency-mismatch" ) {
                                                dependencyMismatch = true;
                                                continue;
                                        }
                                        dependencyMismatch = false;

                                        if ( result == "pending" ) {
                                                this.toHide = this.toHide.not( 
this.errorsFor(element) );
                                                return;
                                        }

                                        if( !result ) {
                                                this.formatAndAdd( element, 
rule );
                                                return false;
                                        }
                                } catch(e) {
                                        this.settings.debug && window.console 
&& console.log("exception
occured when checking element " + element.id
                                                 + ", check the '" + 
rule.method + "' method");
                                        throw e;
                                }
                        }
                        if (dependencyMismatch)
                                return;
                        if ( this.objectLength(rules) )
                                this.successList.push(element);
                        return true;
                },


See comment "if radio/checkbox, validate first element in group
instead", so validation only happened for first element. I'm not good
at JQuery, any one knows how to fix this bug?





On Aug 14, 10:49 pm, Carlos Becar <ventas.w...@gmail.com> wrote:
> > 2. Checkbox highlight. I am using a class highlight for all the
> > errors. I use required checkbox, so at least 1 checkbox must be
> > checked. If I check the first item, then uncheck, the error message
> > appear and the error class highlight also successfully displayed.
> > However, if I check the second or the third (etc) item, then uncheck,
> > only the error msg appear, the error class doesn't highlight. Here is
> > my code:
>
> >                highlight: function( element, errorClass, validClass  ) {
>
> >  $(element).parents('li').addClass(errorClass).removeClass
> > (validClass);
> >                },
> >                unhighlight: function( element, errorClass, validClass  ) {
>
> >  $(element).parents('li').removeClass(errorClass).addClass
> > (validClass);
> >                },
>
> Example:
>
> function example(errorClass, validClass){
> /*you have to ask if length is equal then */
>     if($("input[name*='chkList']").length ==
> $("input[name*='chkList']:not(:checked)").length){
>         /*show the error class highlight or alerts or your class assigned to
> all checkbox */
>         /* you can add class without send to the function)
>         $("input[name*='chkList']").addClass(errorClass)
>
> >         alert("please select at least one option")
>
>    }
>    else
>    {
>       $("input[name*='chkList']").removeClass(errorClass)
>    }
>
> }
>
> but , i dont know because use "removeClass" or addClass" without respective
> parameters, this not add or remove or fire nothing .
>
> --
> Atte.
> Carlos Becar.

Reply via email to