jQuery - Selecting a div with multiple classes, but searching for just two of them
<p>My title may be a bit unclear so I'll try to explain a bit better.</p>

<p>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.</p>

<p>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.)</p>

<p><strong>HTML</strong></p>

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

<p><strong>jQuery</strong></p>

<pre><code>   $('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;
        }
    }
</code></pre>

<p>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.</p>

<p>Any work around for this?  I could just throw in something like...</p>

<p>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.</p>
