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

  • Home
  • SEARCH
  • 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 9134821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:43:49+00:00 2026-06-17T08:43:49+00:00

<div class=row> <label for=txtTitle>Title</label> <div class=holder> <div class=text-holder> <span class=ico-error></span><span class=text> <input id=txtTitle runat=server

  • 0
<div class="row">
    <label for="txtTitle">Title</label>
    <div class="holder">
        <div class="text-holder"> <span class="ico-error"></span><span class="text"> <input id="txtTitle"
     runat="server" type="text" value="" /></span>  <span class="t-l">
     </span><span class="b-l"></span><span class="t-r"></span><span class="b-r"></span> 
        </div>
    </div>
</div>

I have the following html. I am planning on doing some Jquery validation on the input box. If this is invalid I want to add the error class to the div

        var isValid = true;
        var errorMessage = '';
        if ($('#<%=txtTitle.ClientID %>').val() == '') {
            $('#<%=txtTitle.ClientID %>').parent().parent().parent(".row").addClass("error");
            isValid = false;
            errorMessage += "Firstname is required\n";
        }
        return isValid;

I’ve tried to target the parent but see that this div is further up the parent heirachy. so tried to select up the heirachy with more parent tags, but think I am straying well off course from understanding the correct way to target the 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-06-17T08:43:50+00:00Added an answer on June 17, 2026 at 8:43 am

    I suggest using .closest():

    Description: For each element in the set, get the first element that
    matches the selector by testing the element itself and traversing up
    through its ancestors in the DOM tree.

    var isValid = true;
    var errorMessage = '';
    var $this = $('#<%=txtTitle.ClientID %>');
    
    if ($this.val() == '') {
        $this.closest(".row").addClass("error");
        isValid = false;
        errorMessage += "Firstname is required\n";
    }
    return isValid;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<div class=control-group> <label for=name class=control-label><p class=text-info>Name&nbsp;<i class=icon-star></i></p></label> <div class=controls> <input type=text id=name placeholder=Enter your
I would like to render the following markup: <div class=row> <p> <label>Your Name</label> <input
I am having a Html like .. <div id=Field1> <label id=label1>Name</label><br/> <input type=text data-attr=text
My problem is with the below html <div class=editor-container> <div class=editor-row curFocus> <div class=editor-label>
Please consider following snippet: <div class=row> <div class=span12> <div class=control-group> <label class=control-label>Person Name</label> <div
<div class = a> <div class = a b> text </div> </div> <script> alert($(.a).html());
What is the best way to add another class to this script: <script type=text/javascript>
How do I add a class for the div ? var new_row = document.createElement('div');
I have a div class named switch control which has a div class named
I am trying to hide the div class hideme based on value of full_day

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.