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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:17:52+00:00 2026-05-25T13:17:52+00:00

My title may be a bit unclear so I’ll try to explain a bit

  • 0

My title may be a bit unclear so I’ll try to explain a bit better.

I have a signup form and I’m checking whether all of the required fields are filled or not. For one particular section of the form, I have a div with 7 or 8 classes and I need that div to display if I’m looking for two of them.

Here’s what I’m trying to do that isn’t working.. (this will work when using two specific classes, but not when extra classes are also there.)

HTML

<div class="errors last first address city state zip country email phone" style="display: none;"><span class="error">Required values are missing from your contact information.</span></div>

jQuery

   $('form#finalize').submit(function() {
        var required = ['hostname','first','last','address','city','state','zip','country','email','phone'];
        var result = true;
            $.each(required, function(index, value) {
                if(filledElement(value) == false){
                    $(".item.errors").show().fadeOut(8000);
                    result = false;
                }

            });
            if(checkElement('tos') == false){
                $(".item.errors").show().fadeOut(8000);
                return false;
            }
            return result;
    });


    function filledElement(elem){
        if( isSet(elem) != true ) {
            $('.'+elem+'.errors').show();
            return false;
        }
        else {
            $('.'+elem+'.errors').remove();
            return true;
        }
    }

So once again to clarify.. the issue is in the function filledElement, when it goes to display the error, ‘.’+elem+’.errors’ is looking for an element that only contains those two classes, rather than looking for an element that may contain those two classes and more.

Any work around for this? I could just throw in something like…

if (item in required).. $(‘.errors.first.last.address.phone … etc’).show(); but that just seems unnecessary and it’s not very flexible if my template were to change.

  • 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-25T13:17:53+00:00Added an answer on May 25, 2026 at 1:17 pm

    No, that is not your problem. You don’t need to have all the classes in the selector, having just two of them works fine. Demo: jsfiddle.net/Guffa/fj95m/

    The problem is in the else statement in the filledElement function. If any of the fields is filled in, you remove the error message element.

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

Sidebar

Related Questions

The title may be a bit ambiguous, but I couldn't think of a better
The title may be a bit vague, but here's my goal: I have a
The title may not really explain what I'm really trying to get at, couldn't
Ok so the title may have been confusing so i have posted 2 code
Hey all, title may be abit misleading but i didnt know the correct way
I have model Article it has field title with some text that may contain
Okay so the title may be a bit misleading. What I am trying to
The title of this question may be a bit misleading. I couldn't quite think
The title may sound a bit odd but I wanted to keep the title
The title may be long, let me explain what I mean. I won't give

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.