cyndylove46
asked on
Dreamweaver Radio Button Validation Question
I am working on a form where the user has to select one of two button on 27 different items. I keep get a debug error on my JavaScript and I can't figure out what I'm missing. Here is my code (I have commented out some lines in the middle when the first variable value would not pass). HELP (if possible):
//JavaScript Document
function frmValidate(rdo1, rdo2, frm)
//beginning of how to alert user with two line breaks at end for a double space
var errAlert = "The Following are required:\n\n";
// counter to let you know how man errors exist...no alert if no error present
var errCt = 0;
for (var i=0; i< 4; i++)
{
if (frm(rdo1)[i].checked)
{
errAlert = ""
errCt = 0;
break;
}
else
{
//if there is an error, let's add one to the count
errCt = errCt +1;
}
}
if (errCt > 0)
{
errAlert = errAlert + "-- Question 1" + "\n"
}
/*errCt = 0
for (var j=0; j<=3; j++)
{
if (document.getElementByID(r do2).check ed ==true)
{
errAlert = ""
errCt = 0;
return true;
break;
}
else
{
//if there is an error, let's add one to the count
errCt = errCt +1;
}
}
if (errCt > 0)
{
errAlert = errAlert + " -- Question 2" + "\n"
}
*/
if (errCt > 0)
{
//if the error count is greater than zero, then let's alert the user of what he/she missed.
alert(errAlert);
return false;
}
return true;
}
//JavaScript Document
function frmValidate(rdo1, rdo2, frm)
//beginning of how to alert user with two line breaks at end for a double space
var errAlert = "The Following are required:\n\n";
// counter to let you know how man errors exist...no alert if no error present
var errCt = 0;
for (var i=0; i< 4; i++)
{
if (frm(rdo1)[i].checked)
{
errAlert = ""
errCt = 0;
break;
}
else
{
//if there is an error, let's add one to the count
errCt = errCt +1;
}
}
if (errCt > 0)
{
errAlert = errAlert + "-- Question 1" + "\n"
}
/*errCt = 0
for (var j=0; j<=3; j++)
{
if (document.getElementByID(r
{
errAlert = ""
errCt = 0;
return true;
break;
}
else
{
//if there is an error, let's add one to the count
errCt = errCt +1;
}
}
if (errCt > 0)
{
errAlert = errAlert + " -- Question 2" + "\n"
}
*/
if (errCt > 0)
{
//if the error count is greater than zero, then let's alert the user of what he/she missed.
alert(errAlert);
return false;
}
return true;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The rdo1, rdo2 was supposed to be the variables for radio button selection. That didn't work, and we started looking at checked boxes.