Hi, I need help validating a form, preferably using JQuery:
this is my code:
<form action='index.php' method='post'>
<table>
<tr>
<td>1.</td>
<td><select name='from_1'><option>HOME</option><option>A</option><option>B</option><option>C</option></select></td>
<td><select name='to_1'><option>HOME</option><option>A</option><option>B</option><option>C</option></select></td>
</tr>
<tr>
<td>2.</td>
<td><select name='from_2'><option>HOME</option><option>A</option><option>B</option><option>C</option></select></td>
<td><select name='to_2'><option>HOME</option><option>A</option><option>B</option><option>C</option></select></td>
</tr>
<tr>
<td>3.</td>
<td><select name='from_3'><option>HOME</option><option>A</option><option>B</option><option>C</option></select></td>
<td><select name='to_3'><option>HOME</option><option>A</option><option>B</option><option>C</option></select></td>
</tr>
</table>
<input type='submit' value='submit' />
</form>
I want to add some javascript validation:
when someone clicks on the submit button, the form should be validated (see below).
When it is invalid, an error message should popup (alert or -even better- modal dialog), and the form should not be submitted.
The validation:
each row (in this example 3, but could be more) should contain one and only one time the 'HOME' selection. So either the 'from' or the 'to' option should be HOME.
Can someone help me with this? I know it is quite specific, but it will help me a lot...