Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6378405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:00:04+00:00 2026-05-25T02:00:04+00:00

I’m validating a form with jquery validate, and having a little trouble consistantly setting

  • 0

I’m validating a form with jquery validate, and having a little trouble consistantly setting the error placement. The input field have different levels of nesting, some are in div some are in nested divs. However for all errors I want to be placed in the span with the class ‘warming’ above the input field in question. I have tried closest, parents and seems to not work. I can explicitly traverse the tree but that only works if the elements are at the same level of nesting? I think closest should work but it doesn’t (well I am doing something wrong) any help appreciated.

$("#paymentpreferences").validate({
    rules: {    
        minpayment: {
            digits: true,
            min: 5
            }       
    },
    errorPlacement: function(error, element) {      
        $(element).parents('span .warming :first').html(error);
    },
    success: function(label){           
        label.next().next().addClass('tick');
    }
}); 

Sample Html, see ‘method’ select is in a nested div but the accountno is not

                                    <span class="warming"></span>
                                      <div class="lab_box"><label class="lab">payment type</label></div>
                                        <div class="input_box">
                                            <div class="gender_box">

                                                <select name="method" id="method" tabindex="1" class="ins required">
                                                <option value="1" label="PayPal">PayPal</option>
                                                </select>                                       
                                            </div>
                                            <a href="#" title="tooltip_paymentmethod" class="question tooltips"></a>
                                            <div class=" fill"></div>
                                        </div>
                                        <div class="wb_clear"></div>
                                        <span class="warming"></span>

                                        <div class="lab_box"><label class="lab">account number</label></div>
                                        <div class="input_box">
                                            <span>
                                            <input type="text" name="accountno" id="accountno" value="asdasd" tabindex="2" class="ins required" size="30" />
                                            </span>
                                            <a href="#" title="tooltip_accountno" class="question tooltips"></a>
                                            <div class="fill"></div>
                                        </div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:00:05+00:00Added an answer on May 25, 2026 at 2:00 am

    If you want to specifically specify the error message in a particular div or a span you can just write in error placement for that element something like this.

    if ( element.is("#your_field") )
         error.appendTo('#your_field_err');
    

    Here your_field_err is your error div or span’s ID. and your_field is id of the field.
    Like in your code you’ve mentioned complex structure.
    Please make sure that you place these kind of error placement on the top and most generic like in your code at the bottom.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.