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
the thing is dat i calculate the length of radio button in javascript.
and based on dat i do my validation
but wen 1 radio is der my program take the length as 'undefied'
and becoz of this it does not work
plz help me to sort it out.
im giving my code below
function validate(thisform)
{
var arrayLength = thisform.length;
var checkthis;
var radio_selected;
if (!arrayLength)
{
if (thisform.checked != 1)
{
alert("Please select.");
return false;
}
else
{
document.form1.method="post"
document.form1.action=".php"
document.form1.submit()
}
}
else
{
for (i=0; i < arrayLength; i++)
{
checkthis = thisform[i];
if (checkthis.checked == 1)
{
radio_selected = "yes";
break;
}
}
if (radio_selected != "yes")
{
alert("Please select.");
return false;
}
else
{
document.form1.method="post"
document.form1.action=".php"
document.form1.submit()
}
}
}
dis does not work for wen 1 radio button is der