Forum Moderators: open
I have validated radio buttons and checkboxes, but how would I validate that at least one Qty box (in the type="text" boxes) has a value entered (this is a shortened version of the form, there are actually at least 10 qty's) since each name is different? I know there must be another way other than validating each one individually.
<form name="premier" method="post" action="../forms/proc_pgpkg3.php">
<table width="720" border="0">
<tr align="center">
<td colspan="3"><h3>Package Selection</h3>
<p>You can choose from several options for your monthly package.</p>
</td>
</tr>
<tr>
<td class="right"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="right"><strong>ID No.:</strong></td>
<td> </td>
<td><input name="ID" type="text" id="ID" size="15">
</td>
</tr>
<tr>
<td class="right"><strong>Name:</strong></td>
<td> </td>
<td><input name="Name" type="text" id="Name" size="60"></td>
</tr>
<tr>
<td class="right"><strong>E-Mail Address</strong>:</td>
<td> </td>
<td><input name="Email" type="text" id="Email" size="60"></td>
</tr>
<tr>
<td class="right"><strong>Phone Number:</strong></td>
<td> </td>
<td><input name="Phone" type="text" id="Phone" size="60"></td>
</tr>
<tr>
<td class="right"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="right"><input type="radio" name="Autoship" value="Package_Selection"></td>
<td> </td>
<td>Below is my selection for the Autoship Package</td>
</tr>
<tr>
<td class="right"><input type="radio" name="Autoship" value="Change"></td>
<td> </td>
<td>I am changing my previous Autoship Package selection</td>
</tr>
<tr>
<td class="right"><input type="radio" name="Autoship" value="Separate_Selections"></td>
<td> </td>
<td>I would like to purchase the following package(s) separately from my
Autoship</td>
</tr>
<tr>
<td height="20" colspan="3"> </td>
</tr>
<tr>
<td width="110" height="55" class="right">
PG0401 <br>
<strong>$38.00</strong><br>
<input name="Qty_PG0401" type="text" id="Qty_PG0401" size="3">
Qty<br></td><td width="3"> </td>
<td width="593"><p><strong>Candles</strong><br>
Descriptive text here. <em>Selection
may vary.</em></p>
</td>
</tr>
<tr>
<td class="right"> PG0407 <br>
<strong>$36.00</strong><br>
<input name="Qty_PG0407" type="text" id="Qty_PG0407" size="3">
Qty</td><td> </td>
<td><strong>Casual Gifts</strong><br>
Descriptive text here. <em>Selection
may vary.</em></td>
</tr>
<tr>
<td class="right">PG0410<br>
<strong>$34.00</strong><br>
<input name="Qty_PG0410" type="text" id="Qty_PG0410" size="3">
Qty</td><td> </td>
<td><strong>Gift Wrap</strong><br>
Descriptive text here. <em>Selection may vary.</em></td>
</tr>
<tr>
<td class="right"> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Reset"></td>
</tr>
</table>
</form>
Thank you for any assistance.
mp
// check that at least one quantity is entered if (window.document.premier.Qty_PG0401.value < 1 &&
window.document.premier.Qty_PG0407.value < 1 &&
window.document.premier.Qty_PG0410.value < 1)
{
alert ("You did not enter a quantity.");
return false;
}
return true;
}
When I tried other ways (before posting), I ended up with an array and had a lot of trouble retrieving the values properly with php.
Thanks again,
mp