473,734 Members | 2,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Field validation based on radio button selection

11 New Member
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="JavaS cript" 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 (emptyvalidatio n(op40_LabelShi p,"For overnight FedEx/DHL shipping, you must enter an account numnber.")==fal se) {op40_LabelShip .focus(); return false;};
}
}

//--></script>


<form name="form" onsubmit="formv alidation(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_Labe lShip" checked="checke d"
onclick="javasc ript:document.f orm.ShipperAcct Number.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_Labe lShip"
onclick="javasc ript:document.f orm.ShipperAcct Number.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_Labe lShip"
onclick="javasc ript:document.f orm.ShipperAcct Number.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_Labe lShip"
onclick="javasc ript:document.f orm.ShipperAcct Number.disabled =false" />
DHL Shipping (must specify account number below)<br />





FedEx/DHL Account Number:<input class="text" id="ShipperAcct Number" size="15" name="op40_Labe lShip" /></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/ShoppingCartBut tons/addtocart.gif" value="Submit" border="0" name="add" />[/HTML]
Apr 26 '07 #1
1 3350
acoder
16,027 Recognized Expert Moderator MVP
document.getEle mentsByName("it em_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

3
23887
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"> <input type="submit" name="mainform_action" value="Delete Data"> If the first radio button is selected, I only want all three buttons to be visible to the user. If the second radio button is selected, I only want the "Edit Data" and "View Data"...
2
2893
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. <tr><td><input type="radio" name="item_name" value="Reduced">Reduced</td><td><input type="radio" name="amount" value="25">$25.00ea.</td></tr> <tr><td><input type="radio" name="item_name" value="Regular">Regular</td><td><input type="radio"...
6
21321
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 validation? Thanks -- Paul G Software engineer.
5
2724
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 are selected it should giv message dat select a radio button. else it should go to other page. My code works fine when there are more than 1 radio button but when only 1 radio button is der dat time it does not work
8
4613
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) that need to be validated when the submit button is clicked. Instead of the standard alert window popping up (which I have now), I want the radio button background color to change from the table color (E2E2E2) to red (FF0000) for both buttons...
10
3416
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 selection from select list. Initially I tried to disble the selection control. And when user will click the radio then only it was enabled. but I faced problem that value is not passed to the next form of the select list. so I enable the select list now...
4
3026
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. <form action="" method="get"> <div align="center"> <table border="0" cellspacing="0" cellpadding="0">
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9182
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.