Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic radio button validation-- need help urgently

Status
Not open for further replies.

plange

Programmer
Dec 12, 2001
20
US
HELP! I have a survey where the questions displayed on the site are dynamically pulled from a database and each question has a series of radio buttons. Each question needs to be answered and I thought this would do the trick but it isn't:

<!--
function checkQuestions(which) {
// require at least one radio button be selected per question
for (i = 0; i < which.length; i++) {
if (which.element.checked != true) {
alert(&quot;Please answer every question on this page.&quot;);
}
}
return (false);
}
//-->

the function is obviously being called when form is submitted-- any ideas?!

 
I've revised the js but still no go:

function checkQuestions(which) {
// require at least one radio button be selected per question
isValid = false;
for (i = 0; i < which.length; i++) {
if (which.element.checked) {
isValid = true;
} else {
isValid = false;
break;
}
}
if (not isValid) {
alert(&quot;Please answer every question on this page&quot;);
}
return (isValid);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top