That did it, thanks.

On May 14, 5:42 pm, "Jörn Zaefferer" <[EMAIL PROTECTED]>
wrote:
> Right, because showErrors usually calls highlight/unhighlight, didn't
> thought of that. Try to specify errorPlacement instead.
>
> Jörn
>
> On Wed, May 14, 2008 at 6:17 PM, Gordon <[EMAIL PROTECTED]> wrote:
>
> >  Thanks for the reply.
>
> >  The highlight/unhighlight functions for toggling my li classes work
> >  okay, but unfortunately when I add a showErrors function that does
> >  nothing then the class toggling functions stop doing anything.  All
> >  that happens is the form fails to submit and focus returns to an
> >  invalid field (so I know the validator is working, it's just giving me
> >  no feedback).
>
> >  On May 14, 5:09 pm, "Jörn Zaefferer" <[EMAIL PROTECTED]>
> >  wrote:
>
> > > You can use the highlight/unhighlight options to add and remove the
> >  > additional class. To disable messages disable, specify a function for
> >  > the showErros option that does nothing:
>
> >  > $(...).validate({
> >  >   showErrors: function() {},
> >  >   highlight: function(element) {
> >  >     $(element).parent ().addClass('formerr')
> >  >   },
> >  >   unhighlight: function(element) {
> >  >     $(element).parent ().removeClass('formerr')
> >  >   }
>
> >  > });
>
> >  > Jörn
>
> > > On Wed, May 14, 2008 at 4:07 PM, Gordon <[EMAIL PROTECTED]> wrote:
>
> >  > >  I'm looking into various form validating libraries and one of the ones
> >  > >  I'm considering is jquery.validate.  It appears at first glance to be
> >  > >  very flexible, but its documentation is a bit overwhelming at first
> >  > >  glance!
>
> >  > >  In my forms I'm using the following structure for fields and
> >  > >  associated text.
>
> >  > >  <li>
> >  > >  <label for="foo">
> >  > >  Some text describing the field here
> >  > >  <span class="errormsg">Hidden error message goes here</span>
> >  > >  </label>
> >  > >  <input name="foo" />
> >  > >  </li>
>
> >  > >  I've got css that looks like this:
> >  > >  li label span.errormsg {
> >  > >     display: none;
> >  > >  }
> >  > >  li.formerr label span.errormsg {
> >  > >     display: block;
> >  > >  }
>
> >  > >  Whether or not the error message is visible depends on what class the
> >  > >  li element has.  If the li has a class of "formerr" then the error
> >  > >  message displays (and other formatting is applied to indicate an
> >  > >  error, but as it's not important to the problem at hand I've left that
> >  > >  out).  If the li doesn't have a formerr class then the error message
> >  > >  is hidden.
>
> >  > >  What I need to do is get the validate plugin to toggle the class of
> >  > >  the form control's parent element (the li) depending on if the content
> >  > >  is valid is not
>
> >  > >  $(this).parent ().addClass ('formerr') // Add error class
> >  > >  $(this).parent ().removeClass ('formerr') // remove error class
>
> >  > >  I don't need the validate pligin to do anything else, like add text to
> >  > >  the DOM or anything like that, just toggle the class of the item's
> >  > >  parent.  I just can't figure out how to do that.  My server side
> >  > >  validation adds the formerr class to li items that contain invalid
> >  > >  form controls, it would be nice if my client side validation worked
> >  > >  the same way.  I don't want to have to do things such as write all the
> >  > >  error messages out twice (once for the js and once again for the PHP).

Reply via email to