I'm trying to develop an order page and in one section, the customer specifies a shipment type using radio buttons that is submitted to the shopping cart. There are 4 buttons. If either of the first two are selected, the form should submit the data. If either of the last two are selected, I want the form to require input on a text field to collect an account number (op40_LabelShip). I have gotten the form to require the field, but it requires it no matter which radio button is checked. Also, although the field is required, the form submits the other data anyway. I'm stuck at this point. Any help would be appreciated. Here's what I have:
[HTML]<script language="JavaScript" type="text/JavaScript"><!--
function emptyvalidation(entered, alertbox)
{
with (entered)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}
function formvalidation(thisform)
{
with (thisform)
{
if (emptyvalidation(op40_LabelShip,"For overnight FedEx/DHL shipping, you must enter an account numnber.")==false) {op40_LabelShip.focus(); return false;};
}
}
//--></script>
<form name="form" onsubmit="formvalidation(this);" action="http://www.xyz/cart.cgi" method="post">
<input value="s-9999^=SF==NA=^***Mailing Label Standard Shipping^0.00^1^^^N/A^^"
type="radio" id="ShipStd" name="item_LabelShip" checked="checked"
onclick="javascript:document.form.ShipperAcctNumbe r.disabled=true" />
Standard USPS Delivery For Label Order - No Charge<br />
<input value="s-9999^=SF==NA=^***Bill Express Shipping To Credit Card Used For This Order^0.00^1^^^N/A^^"
type="radio" id="CCShip" name="item_LabelShip"
onclick="javascript:document.form.ShipperAcctNumbe r.disabled=true" />
Bill Label Order Express Shipping To Credit Card Used For This Order<br />
<input value="s-9999^=SF==NA=^***Bill Express Label Order Shipping to FedEx Acct # ^0.00^1^^^N/A^^"
type="radio" id="ExpressShip" name="item_LabelShip"
onclick="javascript:document.form.ShipperAcctNumbe r.disabled=false" />
FedEx Shipping (must specify account number below)<br />
<input value="s-9999^=SF==NA=^***Bill Express Label Order Shipping to DHL Acct # ^0.00^1^^^N/A^^"
type="radio" id="ExpressShip" name="item_LabelShip"
onclick="javascript:document.form.ShipperAcctNumbe r.disabled=false" />
DHL Shipping (must specify account number below)<br />
FedEx/DHL Account Number:<input class="text" id="ShipperAcctNumber" size="15" name="op40_LabelShip" /></p>
<input type="hidden" value="s-9999^=SF==NA=^(op40_LabelShip)^0.00^1^^^N/A^^" /><p align="left"></p>
<hr />
<input type="image" src="../../UploadedImages/ShoppingCartButtons/addtocart.gif" value="Submit" border="0" name="add" />[/HTML]