473,242 Members | 1,319 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,242 software developers and data experts.

Field validation based on radio button selection

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;};


<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]
Apr 26 '07 #1
1 3279
16,027 Expert Mod 8TB
document.getElementsByName("item_LabelShip") should give you the radio buttons. Loop over them and check the checked property of each to get the selected radio button.
Jan 30 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Owen Funkhouser | last post by:
I have a form with three radio options. And I have three buttons: <input type="submit" name="mainform_action" value="Edit Data"> <input type="submit" name="mainform_action" value="View Data">...
by: Stoic | last post by:
I'm offering a selection of three items. One is $25, the second is $50, the third is $100. Along with selection one of the items I need to pass the quantity of the selection. Here is the code now....
by: Paul | last post by:
I am trying to setup a field validator and tried using the control to validate set to a dropdown list box but did not seem to work. Is there anyway to set this up or do you need to use client side...
by: swatidesai0407 | last post by:
hi im validating radio buttons i create dis radio button in php based on some how many records of my query. i wrote a javascript to validate this buttons. wat i do is dat wen no radio button...
by: photoboy | last post by:
I have racked by brain long enough on this, so now I need the help of someone who knows what they are doing. Here is what I am trying to achieve: First, I have two radio buttons (both unchecked)...
by: mukeshrasm | last post by:
Hi I have a html in which there is two selection box and two radio button. Radio buttion is of array type. What I want if user will click the radio button then only he/she be able to make...
by: pureadrenaline | last post by:
Hey Guys, Please could anyone help me out with the following form I need to create a validation on the email field only if the user checked the radio button named Email. Thanks in advance. ...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.