jcdevelopment
09-09-2008, 08:59 PM
I have a large form for a user to fill out. There are probably about 50 different named sections of radio buttons. What would be the easiest way of validating them.
EX of what i have (that doesnt work)
function checkRadio (overview) {
var radios = document[overview];
for (var i=0; i <radios.length; i++) {
if (radios[i].checked) {
return true;
}
}
return false;
alert("bad");
}
html
<form id="overview" name="overview" action="" onsubmit="checkRadio(this)">
<input name="lawn" type="radio" value="g" />
<input name="lawn" type="radio" value="g" />
<input name="lawn" type="radio" value="g" />
<input name="house" type="radio" value="g" />
<input name="house" type="radio" value="g" />
<input name="house" type="radio" value="g" />
and about 48 more of those. Anyone have an easy solution to this, or any help.
Thanks
EX of what i have (that doesnt work)
function checkRadio (overview) {
var radios = document[overview];
for (var i=0; i <radios.length; i++) {
if (radios[i].checked) {
return true;
}
}
return false;
alert("bad");
}
html
<form id="overview" name="overview" action="" onsubmit="checkRadio(this)">
<input name="lawn" type="radio" value="g" />
<input name="lawn" type="radio" value="g" />
<input name="lawn" type="radio" value="g" />
<input name="house" type="radio" value="g" />
<input name="house" type="radio" value="g" />
<input name="house" type="radio" value="g" />
and about 48 more of those. Anyone have an easy solution to this, or any help.
Thanks