views:

666

answers:

1

When configure defaults options for the validator:

$.validator.setDefaults({
    errorElement: "em"
});

and then simple using like:

$("form").validate({});

validator still uses label element and ignore errorElement em that configured in defaults!

What can i do in this case, of course putting errorElement for each instance of validator not a good idea?

+1  A: 

While I'm not sure about the fix for this, I'd strongly suggest using errorClass instead of errorElement, which works fine for me.

By letting the default element "label" you let jQuery Validator create "a meaningful link between error message and invalid field using the for attribute".

You can always adjust how that element (in this case, label) is shown using CSS, and you should always aim to use [X]HTML to stablish semantics of the page rather than look and feel. For the latter, there's CSS.

Seb
my problem is that im using fieldset with label and input, so for another label create css will be ugly trick :(
msony
Mmm... I see. Have you tried another version of the validator? Maybe it's a known bug and you could avoid it by switching versions. I know it's not a great idea, but I'm running out of them :(
Seb