Hey All,

Validating a form, I have a series of optional field pairs
e.g.(item_1_name, item__1_id)
which must be submitted in tandem -- if at all.

I have worked up the following clunky solution, but am certain there's
a far simpler, more elegant (and probably obvious) alternative which is
obscured from my view by a THICK MONDAY FOG! Any suggestions?

(excuse me for a moment now whilst I rub my eyes and wipe this bit of drool from my chin...)
Code:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
<script type="text/javascript">
function validate_pairs(){
	var item_1_name = $('#item_1_name').val();
	var item_1_id = $('#item_1_id').val();
	var pair_1 = item_1_name+item_1_id;
	if((item_1_name || item_1_id) && ((item_1_name == pair_1)||(item_1_id == pair_1))){
		alert('Missing Value for item_1');
        $('#item_1_name').focus();
		return false;	//repeat for item 2,3,...?
	}
}
</script>
<table>	
	<tr>
		<td width="150"><b>ITEM #1:</b></td>
		<td>Name:<input id="item_1_name" type="text"  size="20"></td>				
		<td>ID:<input id="item_1_id" type="text" size="20"></td>
	</tr>
	<tr>
		<td width="150"><b>ITEM #2:</b></td>
		<td>Name:<input id="item_2_name"  type="text" size="20"></td>				
		<td>ID:<input id="item_2_id" type="text" size="20"></td>
	</tr>
</table>
<input type="button" value="Save changes" onclick="validate_pairs();">