I need to perform some validation on the below mentioned HTML, where there exists three rows of records. Within these three table rows are two enterable fields – a select list (“Reason” field) as well as a textarea item (“Comments” field).
For all records in this table, I need to add some validation through the use of jQuery, that will check to see if the user first decides to place the cursor in the textarea field in one of the three table rows, without first making a selection from the select list (i.e. option value cannot be 0), then display an alert indicating that a “Reason selection is required” and place the focus in this “Reason” field.
<table summary="Contacts" class="uReport uReportStandard">
<thead>
<tr>
<th id="CONTCT_NM">Contact Name</th>
<th id="TEL_NO">Telephone
<br/>No.</th>
<th id="STATE">State</th>
<th id="REAS">Reason</th>
<th id="DATE_CALLED">Date
<br/>Contacted</th>
<th id="MPA_COMMENT">Comments</th>
</tr>
</thead>
<tbody>
<tr>
<td headers="CONTCT_NM">Contact A</td>
<td headers="TEL_NO">123456</td>
<td headers="STATE">VIC</td>
<td headers="REAS">
<input type="hidden" name="f01" value="16919" />
<input type="hidden" name="f02" value="100319" />
<select name="f10" id="selectLOV1" class="lov_select">
<option value="0">--- Please select a reason ---</option>
<option value="1" selected="selected">Contacted / Spoken</option>
<option value="2">Contacted / Unavailable</option>
<option value="3">Other</option>
</select>
</td>
<td headers="DATE_CALLED">
<input type="text" name="f20" size="14" maxlength="2000" value="30/08/2012 09:42"
class="date_val" readonly="readonly" style="background-color:#B0C4DE;border:1px solid #999999;"
/>
</td>
<td headers="COMMENT">
<textarea name="f30" rows="2" cols="30" wrap="VIRTUAL">Contact A</textarea>
</td>
</tr>
<tr>
<td headers="CONTCT_NM">Contact B</td>
<td headers="TEL_NO">123456</td>
<td headers="STATE">VIC</td>
<td headers="REAS">
<input type="hidden" name="f01" value="16919" />
<input type="hidden" name="f02" value="100314" />
<select name="f10" id="selectLOV2" class="lov_select">
<option value="0">--- Please select a reason ---</option>
<option value="1" selected="selected">Contacted / Spoken</option>
<option value="2">Contacted / Unavailable</option>
<option value="3">Other</option>
</select>
</td>
<td headers="DATE_CALLED">
<input type="text" name="f20" size="14" maxlength="2000" value="30/08/2012 09:42"
class="date_val" readonly="readonly" style="background-color:#B0C4DE;border:1px solid #999999;"
/>
</td>
<td headers="COMMENT">
<textarea name="f30" rows="2" cols="30" wrap="VIRTUAL">Contact B</textarea>
</td>
</tr>
<tr>
<td headers="CONTCT_NM">Contact C</td>
<td headers="TEL_NO">123456</td>
<td headers="STATE">VIC</td>
<td headers="REAS">
<input type="hidden" name="f01" value="16919" />
<input type="hidden" name="f02" value="100312" />
<select name="f10" id="selectLOV3" class="lov_select">
<option value="0">--- Please select a reason ---</option>
<option value="1" selected="selected">Contacted / Spoken</option>
<option value="2">Contacted / Unavailable</option>
<option value="3">Other</option>
</select>
</td>
<td headers="DATE_CALLED">
<input type="text" name="f20" size="14" maxlength="2000" value="30/08/2012 09:42"
class="date_val" readonly="readonly" style="background-color:#B0C4DE;border:1px solid #999999;"
/>
</td>
<td headers="COMMENT">
<textarea name="f30" rows="2" cols="30" wrap="VIRTUAL">Contact C</textarea>
</td>
</tr>
</tbody>
</table>
I hope that I’ve understood you correctly:
edit: sorry i forgot about the alert : http://jsfiddle.net/HuVUL/1/