[thelist] validating radio buttons
Cymbala, Greg
Greg.Cymbala at Den.Galileo.com
Thu Jul 11 17:00:01 CDT 2002
Here's one that I've used -- pass in a reference to a radio button
(array/collection of radio buttons, usually) and it'll give you either a
blank string, or the value of the selected radio button. One problem -- if
you have a radio button whose value is "", it could cause confusion, but you
could adapt it to return null or something instead of a zero-length string.
function getSelectedRadioValue (oRadio) {
var vReturn = "";
if (oRadio) { // Check that there is a radio!
if (!oRadio.length) {
// oRadio exists, but length is 0?
if (oRadio.checked) {
return oRadio.value;
} else {
return vReturn;
}
}
if (oRadio.length == 1) {
// Only one radio button - return its value ???
if (oRadio[0].checked) {
vReturn = oRadio[0].value;
}
} else {
// More than one radio button
for (i = 0; i < (oRadio.length); i++) {
if (oRadio[i].checked) {
// Return the checked radio button's value
vReturn = oRadio[i].value;
break;
}
}
}
} else {
// There's no oRadio
}
return vReturn;
}
-----Original Message-----
From: Andrew LaVallee [mailto:andrew at andrewlavallee.com]
Sent: Thursday, July 11, 2002 3:47 PM
To: thelist at lists.evolt.org
Subject: [thelist] validating radio buttons
Is there a way to JS-validate radio buttons to make sure that users select
one? I can pre-populate one, but I'd prefer to keep them totally blank.
..............................
Andrew LaVallee
andrew at andrewlavallee.com
http://www.andrewlavallee.com/
--
For unsubscribe and other options, including
the Tip Harvester and archive of thelist go to: http://lists.evolt.org
Workers of the Web, evolt !
The information in this electronic mail message is sender's business
Confidential and may be legally privileged. It is intended solely for the
addressee(s). Access to this Internet electronic mail message by anyone
else is unauthorized. If you are not the intended recipient, any
disclosure, copying, distribution or any action taken or omitted to be taken
in reliance on it is prohibited and may be unlawful.
The sender believes that this E-mail and any attachments were free of any
virus, worm, Trojan horse, and/or malicious code when sent. This message and
its attachments could have been infected during transmission. By reading
the message and opening any attachments, the recipient accepts full
responsibility for taking protective and remedial action about viruses and
other defects. Galileo International is not liable for any loss or damage
arising in any way from this message or its attachments.
More information about the thelist
mailing list