I have several select boxes and textboxes with the same class and I have the following statement. UPDATED
//This goes through each visible tr of the table with class notEmptyTable
$('.notEmptyTable tr:visible').each(function(index) {
//This checks that the elements with class checkTextBox1IsNotEmpty its not Empty.
if ($('.checkTextBox1IsNotEmpty ').val() != "") {
if ($('.selTxtClass:visible').val() == "") {
$('.selTxtClass:visible').focus();
}
}
});
UPDATE HTML
<table>
<tr>
<td><input type="text" id="txtBoxa1" class="checkTextBox1IsNotEmpty"/></td>
<td><input type="text" id="txtBoxb1" /></td>
<td><select id="selc1" class="selTxtClass" onchange="javascript:if (this.value = "other")txtBoxd1.style.display = 'block'"/>
<input id="txtBoxd1" style="display:none;" class="selTxtClass"/>
</td>
</tr>
<tr>
<td><input type="text" id="txtBoxa1" class="checkTextBox1IsNotEmpty"/></td>
<td><input type="text" id="txtBoxb1" /></td>
<td><select id="selc1" class="selTxtClass" onchange="javascript:if (this.value = "other")txtBoxd1.style.display = 'block'"/>
<input id="txtBoxd1" style="display:none;" class="selTxtClass"/>
</td>
</tr>
<tr>
<td><input type="text" id="txtBoxa1" class="checkTextBox1IsNotEmpty"/></td>
<td><input type="text" id="txtBoxb1" /></td>
<td><select id="selc1" class="selTxtClass" onchange="javascript:if (this.value = "other")txtBoxd1.style.display = 'block'"/>
<input id="txtBoxd1" style="display:none;" class="selTxtClass"/>
</td>
</tr>
</table>
If I do an alert with ($('.selTxtClass:visible').val()) it comes as undefined.
I want to check that the value of these elements are empty, but I cant see what is wrong with this if statement, could you give me a hand, please?
Thanks a lot.