Oops, hit send accidentally. The problem was that I didn't need to
iterate over each error. A single call to showErrors handles them all.

if(data.status == false) {
    // update form errors
    $("#calib_entry").validate().showErrors(data.errors);
}


On May 7, 10:39 am, Brad <nrmlcrpt...@gmail.com> wrote:
> The .each is the problem:
>
> if(data.status == false) {
> // update form errors
>                                                 
> $("#calib_entry").validate().showErrors(data.errors);
>
> }
>
> On May 7, 10:35 am, Brad <nrmlcrpt...@gmail.com> wrote:
>
> > I'm using the validation plugin to perform client side validation on a
> > form that uses $.post.
> > To be safe, I also re-validate all inputs on the server side. Ideally
> > I'll never have a case where client-side validation passes but server-
> > side validation fails, but in case I do, I want to display errors back
> > that the browser.
>
> > I have my server side code returning a JSON object. It contains a
> > status, an errors object, and an info object. The errors object may
> > contain multiple errors.
>
> > $.post("ajax.php",
> >   formdata += '&from=calib&type=submit',
> >   function(data){
> >     if(data.status == false) {
> >       // update form errors
> >       $.each(data.errors, function(fld,msg) {
> >         console.log(fld,msg); // See what's coming back. Looks OK!
> >         var v = $("#calib_entry").validate(); // because of scoping
> > issues I need to redefine validator
> >         v.showErrors({fld:msg}); // <= This is throwing a jQuery error
> >       });
> >     }
> >     ...
> >   },
> >   'json'
> > );
>
> > I'm testing my server side validation and have hard-coded bad value so
> > validation will fail.
> > When I call v.showErrors Firebug is showing an error within jQuery
> > itself. Unfortunately the server I'm working against has a minified
> > version installed (I've requested they install the full version).
>
> > Until I can see where jQuery is failing, can someone who is more
> > familiar with showErrors tell if the problem is how I'm calling it?
> > The console.log call shows that fld and msg are both strings.
>
> > Thanks,
>
> > Brad

Reply via email to