Solved

jquery errorPlacement

Posted on 2014-09-25
3
188 Views
Last Modified: 2014-10-01
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

0
Comment
Question by:erikTsomik
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40344110
use a span instead a div line 13
0
 
LVL 19

Author Comment

by:erikTsomik
ID: 40344162
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

0
 
LVL 82

Expert Comment

by:leakim971
ID: 40344379
no, but you can give it more width with it's parent, so change the width of its parent container
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now