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 6052427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:55:39+00:00 2026-05-23T07:55:39+00:00

This is very frustrating. This is part of some code written for a form.

  • 0

This is very frustrating. This is part of some code written for a form. The input element that is associated with a validation error should display a red border. It works with the .css method, but I’d be grateful if someone could show me why the .addClass method isn’t working.

<style type="text/css">
    .field_error{color:red;}
    .red_border{border:1px solid red;}
</style>

<script>
    $(document).ready(function(){
        $('.field_error').siblings().addClass('red_border');
    });
</script>
...
<label class="description" for="element_1">Email Address </label>
            <div>
            <input id="element_1" name="email" class="element text medium" type="text"/> 
                {% if form.email.errors %}
                    <div class="field_error">{{form.email.errors}}</div>

                {% endif %}
                     </div>

                      ..etc..

If assign “element_1” only one class, it works just fine.

I can also do this instead:

$('.field_error').siblings().css("border", "1px solid red"); 

However, I plan on adding a lot of content to the class I will add. Is there a way to get the addClass method to work?

Thanks!!

Matt

IMPORTANT EDIT

I forgot to add in the multiple classes on my code. No wonder some people are confused. Please review code again.

<input id="element_1" name="email" class="element text medium" type="text"/> 

Solved

The problem was that I had css file that defined the borders of the text input element already. Fixed now. Thanks to all who brain stored with me.

  • 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-23T07:55:40+00:00Added an answer on May 23, 2026 at 7:55 am

    Works for me: http://jsfiddle.net/JAAulde/KPckC/1/ (updated with your multiple class correction)

    You do have a typo in your code, though:

    <input id="element_1" name="email" class="element type="text"/>
    

    should be

    <input id="element_1" name="email" class="element" type="text"/>
    

    Maybe that exists in your live site?

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

Sidebar

Related Questions

This question is sparked by a very frustrating problem that I find is a
First of all thanks in advance, this has been very frustrating and I'm hoping
This very simple code gives me tons of errors: #include <iostream> #include <string> int
This very simple code: #include <iostream> using namespace std; void exec(char* option) { cout
I've written this very simple function to replace a file extension using LINQ in
This is very frustrating, if I search for a variable in a vb file
For a specific example, consider atoi(const std::string &) . This is very frustrating, since
This is very frustrating... I can set the Configuration File for a Windows Forms
This is probably silly but very frustrating. Using VS2008 with a C++ project, when
I was reading this very useful article and noticed that a Windows Phone application

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.