Check radio group for selected elements with Prototype
Just a quick one today.
Here's a little snippet on how you can check if any element of a radio button group is selected, using Javascript and the Prototype library.
function $FR(formElement, radioName) {
var el = formElement.getInputs('radio', radioName).find(function(radio) { return radio.checked; });
return el;
}
Usage:
var theform = $("mainform");
if ($FR(theform, "radio_group_name")==undefined) {
alert("Please select at least one element of the radio group");
}