Targeting multiple elements
Greetings all,
This is my first post to this forum.
I am putting together a validation function and am having trouble with targeting multiple elements.
Here is the relevant portion of markup:
-
<div id="gds">
<labelMunicipal Taxes</label><input type="text" id="municipalTaxes" /><div class="errmsgB" id="municipalTaxes_msg"></div>
<label>School Taxes</label><input type="text" id="schoolTaxes" /><div class="errmsgB" id="schoolTaxes_msg"></div>
<label>Heating Costs</label><input type="text" id="heatingCosts" /><div class="errmsgB" id="heatingCosts_msg"></div>
</div>
an onclick event fires my validation function. If any of the fields are empty, the appropriate error message should display.
The jquery:
-
$('#' + $("#gds input:text[value='']").attr('id') + '_msg').css('display','block');
This sort of works. If all of the fields are empty, only the error message of the first element is displayed, not all 3.
What am I doing wrong?
Regards,
MizPippz