hendryk
07-26-2002, 05:08 PM
Hi,
This function works fine except when the form field is a combo box. When one of the options is selected it still gives the error message "....this is a required field. Please enter a value."
What is going on?
K
function validateFields (aform)
{ var fieldArray =["hospUnitNo","gp","bwt","workingDiagnosis"];
var userNames = ["Hosp.& Unit No.","GP","Birth Weight","Working Diagnosis"];
var fieldName = "";
var field = "";
var decision = true;
var prompt = "";
var i = 0;
for (i = 0; i<fieldArray.length;i++)
{
field =eval("aform." + fieldArray[i]);
if(field.value =="")
{
fieldName = userNames[i];
decision = false;
break;
}
}
if (!decision){alert(fieldName + " is a required field. Please enter a value.");}
else { aform.submit(); prompt = "The form is being submitted.";alert(prompt);}
}
This function works fine except when the form field is a combo box. When one of the options is selected it still gives the error message "....this is a required field. Please enter a value."
What is going on?
K
function validateFields (aform)
{ var fieldArray =["hospUnitNo","gp","bwt","workingDiagnosis"];
var userNames = ["Hosp.& Unit No.","GP","Birth Weight","Working Diagnosis"];
var fieldName = "";
var field = "";
var decision = true;
var prompt = "";
var i = 0;
for (i = 0; i<fieldArray.length;i++)
{
field =eval("aform." + fieldArray[i]);
if(field.value =="")
{
fieldName = userNames[i];
decision = false;
break;
}
}
if (!decision){alert(fieldName + " is a required field. Please enter a value.");}
else { aform.submit(); prompt = "The form is being submitted.";alert(prompt);}
}