Alfred
Alfred

Reputation: 21396

Jquery error placement

I have a form validated using jquery validate plugin. The form consists of 3 columns and several rows like below

+______+____________+________________+
|Title |input field |error placement | 
+------+------------+----------------+

the normal error placement is

errorPlacement: function(error, element) {
                     error.appendTo( element.parent().next() );
                 },

but I want to display elements in a <td> or <div> having name and id as "errorbox", located on the first blank row.

How should I modify the syntax to do this??

Thanks in advance.. :)

blasteralfred

Upvotes: 0

Views: 3703

Answers (3)

Marcjae
Marcjae

Reputation: 13

Umh, both wrong.

Simply do a find.

Eg.

if(element.hasClass("myInputClass")) {
    error.appendTo(element.parents('tr').siblings().children().find('#errorbox'));
}

Wouldnt recommend using an ID though, as it wont be reusable.

Upvotes: 1

hodl
hodl

Reputation: 1420

No, it's:

errorPlacement: function(error,element){
  $(".something_class_here").text("Your customer error");
}

Upvotes: 0

Robin Whittleton
Robin Whittleton

Reputation: 6339

Probably something like:

errorPlacement: function(error, element) {
  error.appendTo($('#errorbox'));
},

However, I’d suggest looking at the errorContainer option as this probably does more what you’re looking for.

Upvotes: 0

Related Questions