Ber53rker
Ber53rker

Reputation: 649

JQuery Form Validation Error Placement

So, I basically want to do something like this: http://jsfiddle.net/bUV6S/1/ ...

But I want to do it using the validate.js. Is it possible to target multiple textboxes using:

            errorPlacement: function (error, element) {
                error.appendTo($("#textUsername"));
            }

...in some way? Thanks.

Upvotes: 0

Views: 593

Answers (2)

Anfurny
Anfurny

Reputation: 134

Have you tried making all of the things you wish to append to in the same css someclass and using a class selector? error.appendTo(".someclass"); ?

Upvotes: 0

Jasper
Jasper

Reputation: 76003

You can append to multiple elements like this:

error.appendTo("#textUsername, #textPassword");

Here is the documentation link for "Multiple Selectors": http://api.jquery.com/multiple-selector/

Here is a jsfiddle appending to multiple elements: http://jsfiddle.net/jasper/Wa8EA/

Upvotes: 1

Related Questions