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 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

my problem is that im using fieldset with label and input, so for another label create css will be ugly trick :(
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 :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.