I have not had any luck anywhere else, so I thought I would try here. I am having a problem with some javascript that I have written. If anyone can help out, that would be great. The error I am receiving, is inside the switch statement. It seems that (FieldList) is not being replaced with it's value in the statement.
Here is the code:
function ValidateForm()
{
FieldCount = 20;
bolPassage = true;
FieldList = new Array(20);
FieldType = new Array(20);
AlertList = new Array(20);
FieldList[0] = "FirstName";
FieldType[0] = "text";
AlertList[0] = "Please enter your First Name";
FieldList[1] = "LastName";
FieldType[1] = "text";
AlertList[1] = "Please enter your Last Name";
FieldList[2] = "Address";
FieldType[2] = "text";
AlertList[2] = "Please enter your Address";
FieldList[3] = "City";
FieldType[3] = "text";
AlertList[3] = "Please enter your City";
FieldList[4] = "State";
FieldType[4] = "selectbox";
AlertList[4] = "Please select a State";
FieldList[5] = "Zip";
FieldType[5] = "text";
AlertList[5] = "Please enter your Zip Code";
FieldList[6] = "DaytimePhone";
FieldType[6] = "text";
AlertList[6] = "Please enter your day time phone number";
FieldList[7] = "EmailAddress";
FieldType[7] = "text";
AlertList[7] = "Please enter your email address";
FieldList[8] = "ArrivalMonth";
FieldType[8] = "selectbox";
AlertList[8] = "Please select the month of your arrival";
FieldList[9] = "ArrivalDay";
FieldType[9] = "selectbox";
AlertList[9] = "Please select the day of your arrival";
FieldList[10] = "ArrivalYear";
FieldType[10] = "selectbox";
AlertList[10] = "Please select the year of your arrival";
FieldList[11] = "DepartureMonth";
FieldType[11] = "selectbox";
AlertList[11] = "Please select the month of your Departure";
FieldList[12] = "DepartureDay";
FieldType[12] = "selectbox";
AlertList[12] = "Please select the day of your Departure";
FieldList[13] = "DepartureYear";
FieldType[13] = "selectbox";
AlertList[13] = "Please select the year of your Departure";
FieldList[14] = "SpaVisitMonth";
FieldType[14] = "selectbox";
AlertList[14] = "Please select the month for your spa visit";
FieldList[15] = "SpaVisitDay";
FieldType[15] = "selectbox";
AlertList[15] = "Please select the day for your spa visit";
FieldList[16] = "SpaVisitYear";
FieldType[16] = "selectbox";
AlertList[16] = "Please select the year for your spa visit";
FieldList[17] = "NameOnCard";
FieldType[17] = "text";
AlertList[17] = "Please enter the name on the credit card";
FieldList[18] = "CreditCardNumber";
FieldType[18] = "text";
AlertList[18] = "Please enter credit card number";
FieldList[19] = "CardExpiresMonth";
FieldType[19] = "selectbox";
AlertList[19] = "Please select the expiration month of your credit card";
FieldList[20] = "CardExpiresYear";
FieldType[20] = "selectbox";
AlertList[20] = "Please select the expiration year of your credit card";
for (i = 0; i < FieldCount; i++)
{
switch (FieldType[i])
{
case "text" :
if (document.SpaForm.FieldList[i].value == "")
{
alert(AlertList[i]);
document.SpaForm.FieldList[i].focus();
bolPassage = false;
}
break;
case "selectbox" :
if (document.SpaForm.State.selectedIndex == 0)
{
alert(AlertList[i]);
document.SpaForm.FieldList[i].focus();
bolPassage = false;
}
break;
}
}
if (bolPassage == true)
{
return true;
}
else
{
return false;
}
}