I have looked through many different questions here (as well as through Google) and have not been able to find an answer which comes close to what I am looking for.
I have a form (set up using tables) which has multiple radio button groups that I am trying to validate using JS. I know that I could write a function for each group which would accomplish the desired task however I am trying to simplify my JS script using as few functions as possible so here goes.
I am trying to write a function that will check which radio button is selected and perform a different task depending on which selection is made.
HTML Code:
<tr>
<td class="left"><span class="required">*</span>Only approved Ingredients Used:</td>
<td>
<label><input name="approve" type="radio" required id="approve_0" value="Yes">Yes</label>
<label><input name="approve" type="radio" required id="approve_1" value="No">No</label>
</td>
</tr>
For each section like this (and I have around 15 of these sections) I am trying to us an "onChange="somefunction()" call which will result in an error message "(label name) must be completed" as well as cause a text box to appear for the user to input "corrective actions" in before submitting the form.
Any help would be greatly appreciated
I also would like to stay away from jquery