I am trying to validate the form so that mandatory fields are filled, some how it does not allow me to add the Return True and Return False… Also mandatory fields are mandatory when there is a question in the QuestionField
the form looks like this
Question1
R1
Question2
R2
up to 30 questions…
// Check each of the required fields and return and error listing any mandatory fields that fail validation
var errString;
var frm = document.forms[0];
var flds = new Array();
// validate the listbox field first, then the remaining fields
// validate the radio button fields
var r1 = document.forms[0].R1.length;
var i;
var y;
y = “0”
for(i = 0; i<r1; i++)
{
if(document.forms[0].R1[i].checked)
{
y = y + “1”
}
y = y + “0”
}
if (y == “000”) // 3 zeros means that there was no selection made in the radio button field
{
errString = errString + "please enter..." ?" + '\r\n'
}
var r1 = document.forms[0].R2.length;
var i;
var y;
y = “0”
for(i = 0; i<r1; i++)
{
if(document.forms[0].R2[i].checked)
{
y = y + “1”
}
y = y + “0”
}
if (y == “000”) // 3 zeros means that there was no selection made in the radio button field
{
errString = errString + "please enter..." + '\r\n'
}
…
… it goes up to 30 fields
// list text fields to validate below
// The text in quotes is what is added to to errString and returned to the user.
flds[flds.length] = [frm.R1, “aaaaaa”];
flds[flds.length] = [frm.R2, “aaa”];
…
…
// loop through the array of fields validating each one
for (var i = 0; i < flds.length; i ++)
{
if ( flds[i][0].value == “” )
{
//if the field fails validation, add it to the string
errString = errString + flds[i][1] + '\r\n' ;
}
}
if (errString == “”) // if nothing is added to the errString, all fields passed validation, if not return the list of fields that failed
{
return true ;
}
{
// return one alert box with the list of fields that failed validation
alert("The following information is required:" + '\r\n' + errString)
return false;
}
It does not let me save the return.....
Any ideas…
A.