Looking for a way to extend this input validation
<p>I'm collecting form input values and using localstorage to save them.</p>

<p>Here's the code that checks one of the inputs and performs what I want—but for just one input:</p>

<pre><code>$('#refresh').click(function() {
    if (localStorage['t'] == null || localStorage['t'].length == 0) {
        $("input#t").css("background-color", "yellow");
        return;
    }
    save_data()
    window.location = 't4.html';
});
</code></pre>

<p>​
So, I will have more input values (t, t1, t2 ...) and would like to highlight any/all of the empty ones as performed in the sample. A validation plugin seems unnecessary since this is the only place validation will be needed. Plus, I prefer not to check upon input entry but only when <code>#refresh.click</code> is performed so there is only one "nag" for the user.</p>

<p>Thanks from the newbie for your help!</p>

<p><strong>UPDATE:</strong> <code>.each</code> was suggested but suspect there must be a better way than this:</p>

<pre><code>  $('#refresh').click(function () {

      $("input").each(function (i) {

        if(localStorage['t'] == null || localStorage['t'].length == 0 ) {
        $("input#t").css("background-color","yellow");
        return;
        } 

        if(localStorage['t1'] == null || localStorage['t1'].length == 0 ) {
        $("input#t1").css("background-color","yellow");
        return;
        }

        if(localStorage['t2'] == null || localStorage['t2'].length == 0 ) {
        $("input#t2").css("background-color","yellow");
        return;
        }

        if(localStorage['t3'] == null || localStorage['t3'].length == 0 ) {
        $("input#t3").css("background-color","yellow");
        return;
        }

        else {

        save_data()

        window.location = 't4.html';
        }
      });
    });
</code></pre>
