Check in jquery each if some attribute length is equal to something and add some class to ALL elements which attribute will fit to if statement
<p>I have a form and wanna do validation but not for all in separate, wanna do in each so will not write extra code. Here is my code below</p>

<pre><code>jQuery(".editable_addressItem_parent input[type=text]").each(function () {
    if (jQuery(this).prev("label").children("abbr").length == 1) {
          jQuery(this).parent().addClass('invalidinput');
          jQuery(this).css({'border':'1px solid #ff0000'});
          valid = false;
          return false;
    }else{
          jQuery(this).css({'border':'1px solid #5ee1a2'});
    }
 });
</code></pre>

<p>And here is the markup</p>

<pre><code>&lt;div class="shipping_address_wholewrap shipping_default_address editable_addressItem_parent"&gt;
&lt;div class="shipping_address address_block one_address_item editable_addressItem" id="shipping_address_1"&gt;
&lt;p class="form-row form-row form-row-first validate-required formrow_editscreen" id="shipping_first_name_field"&gt;
    &lt;label for="shipping_first_name" class="" style="display: inline;"&gt;First Name 
        &lt;abbr class="required" title="required"&gt;*&lt;/abbr&gt;
    &lt;/label&gt;
    &lt;input type="text" class="input-text editable_fields" name="shipping_first_name[]" id="shipping_first_name" placeholder="Type here..." value="Test two" style="border: 1px solid rgb(255, 0, 0);"&gt;
&lt;/p&gt;
&lt;p class="form-row form-row form-row-last validate-required formrow_editscreen shipping_last_name_field_editscreen" id="shipping_last_name_field"&gt;
&lt;label for="shipping_last_name" class="" style="display: inline;"&gt;Last Name 
    &lt;abbr class="required" title="required"&gt;*&lt;/abbr&gt;&lt;/label&gt;&lt;input type="text" class="input-text editable_fields" name="shipping_last_name[]" id="shipping_last_name" placeholder="Type here..." value="Testing"&gt;
&lt;/p&gt;
&lt;div class="clear"&gt;&lt;/div&gt;
&lt;p class="form-row form-row form-row-wide address-field update_totals_on_change validate-required formrow_editscreen" id="shipping_country_field"&gt;
&lt;label for="shipping_country" class="" style="display: inline;"&gt;Country / Region 
    &lt;abbr class="required" title="required"&gt;*&lt;/abbr&gt;
&lt;/label&gt;
&lt;select name="shipping_country[]" id="shipping_country" class="country_to_state country_select  shipping_address_select_editscreen editable_fields"&gt;
&lt;option value=""&gt;Select a country…&lt;/option&gt;
&lt;option value="AX"&gt;Åland Islands&lt;/option&gt;
&lt;option value="AF"&gt;Afghanistan&lt;/option&gt;
&lt;option value="AL"&gt;Albania&lt;/option&gt;
&lt;option value="DZ"&gt;Algeria&lt;/option&gt;
&lt;/select&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;div class="shipping_default_addresswrap"&gt;
    &lt;input type="checkbox" class="default_shipping_address" checked="" value="true"&gt; Default address
    &lt;input type="hidden" class="hidden_default_shipping_address" name="shipping_address_is_default[]" value="true"&gt;
&lt;/div&gt;
</code></pre>

<p></p>

<p>With this code it works but only for ONE first input. How i can update the code so it will apply for ALL invalid or empty input fields?</p>

<p>Thanks in advance.</p>