JQuery Find Elements in Proximity to Other Elements
<pre><code>&lt;asp:GridView ID="GridView1"&gt;
  &lt;Columns&gt;
     &lt;asp:TemplateField&gt;
       &lt;ItemTemplate&gt;
           &lt;asp:DropDownList&gt;&lt;/asp:DropDownList&gt; 
           &lt;input type="tel" id="contract"&gt;
       &lt;/ItemTemplate&gt;
     &lt;/asp:TemplateField&gt;
     &lt;asp:TemplateField&gt;
       &lt;ItemTemplate&gt;
           &lt;asp:Label&gt;&lt;asp:Label&gt;
           &lt;asp:Label&gt;&lt;asp:Label&gt;
       &lt;/ItemTemplate&gt;
     &lt;/asp:TemplateField&gt;
     &lt;asp:TemplateField&gt;
       &lt;ItemTemplate&gt;
           &lt;input type="tel" id="Hours"&gt;
       &lt;/ItemTemplate&gt;
     &lt;/asp:TemplateField&gt;
  &lt;/Columns&gt;
&lt;/asp:GridView&gt;
</code></pre>

<p>I am trying to use JQuery as a quick way to validate the template fields in my GridView.  For example, if the SelectedValue of my DropDownList = RENT READY, then the Hours input should not be blank.  So I want to use JQuery to get a count of all times that I can narrow down to a select with a value of RENT READY whose corresponding Hours input = blank.  I've tried:</p>

<pre><code>$("#GridView1 select[value=RENT READY]").find("input[type=tel]").eq(1)
</code></pre>

<p>and</p>

<pre><code>$("#GridView1 select[value=RENT READY]").next("input[type=tel]").next("input[type=tel]")
</code></pre>

<p>and</p>

<pre><code>$("#GridView1 select[value=RENT READY]").next("input[type=tel value=''])
</code></pre>

<p>But always returns undefined.  The select piece works just fine.  It has no problem finding the selects with a value of RENT READY. It's the 2nd piece where I try to narrow it down further to just the selects with an input relative 2 doors down with a blank value that isn't working.</p>

<p><img src="http://i.stack.imgur.com/5FxkK.png" alt="enter image description here"></p>

<p>Edit:  Final Code</p>

<pre><code>$('#GridView1 select').filter(function () {
            return ($(this).val() == 'RENT READY');
        }).closest('tr').find('input[type=tel]').filter(function () {
            return ($(this).val() == "" &amp;&amp; $(this).attr("id") == "Hours");
        }).length
</code></pre>
