Solved

jquery errorPlacement

Posted on 2014-09-25
3
190 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

867 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

20 Experts available now in Live!

Get 1:1 Help Now