On 09/03/07, Jörn Zaefferer <[EMAIL PROTECTED]> wrote:
> Sam Collett schrieb:
> > You could probably use CSS for that, but before you do, errorPlacement
> > needs to change (i.e. don't add the <br>)
> >
> > errorPlacement: function(error, element) {
> >    $(element).before(error);
> > },
> >
> > And your CSS:
> >
> > label.error {
> >   position: relative;
> >   margin-top: -1em;
> > }
> >
> > The problem with that is that it may obstruct some text or an input
> > above (without seeing how your page looks, there is no way to know).
> Sam, keep in mind that the element is already inside the document, but
> the error label is not. And both are jQuery objects, so this should work:
>
> errorPlacement: function(error, element) {
>         error.insertBefore(element);
> }
>
> --
> Jörn Zaefferer
>
> http://bassistance.de

Didn't realise that - I thought they were just DOM elements. The CSS
should still be interpreted even if the error label is not originally
on the page.

Using insert before would mean the text input shifts when the error
shows (i.e. moves right), but with CSS you could style it so this
doesn't happen.

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to