Link to home
Start Free TrialLog in
Avatar of erikTsomik
erikTsomikFlag for United States of America

asked on

jquery errorPlacement

I am trying to do a jquery validation and place the error message next to the field. Currently it goes after the field. I am using a table structure. So it goes in the same cell as a form element. What I want to do is may be creating a separate cell


 errorPlacement: function(error, element) {

   				if (element.attr('type') === 'radio') {
			      error.insertAfter(
          		  element.siblings('input[type="radio"][name="' + element.attr('name') + '"]:last'));
   				}else {
			      error.insertAfter(element);
   				}


<td>
<input id="firstname" class="error" type="text" required="" value="" name="firstname" maxlength="50" size="20">
<div class="error" htmlfor="firstname" generated="true">Please enter the First Name.</div>
</td> 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of erikTsomik

ASKER

That is better but now the error messages does not wrap if they exceed the length they are going to a different line. can i specify the width.

here is my css

#register span.error {
 	background: none repeat scroll 0 0 red;
    border: 2px solid #fff;
    border-radius: 7px;
    box-shadow: 12px 0 7px #000;
    color: #fff;
    margin: 0;
    opacity: 0.7;
    padding: 5px 10px;
    /*position: absolute;*/
    right: -60px;
    top: -92px;
}
#register span.error:before {

position:absolute;
bottom:-36px;
height:36px;
}

Open in new window

no, but you can give it more width with it's parent, so change the width of its parent container