hendryk
07-25-2002, 04:42 PM
Hi,
The array contains the field names in the form - I will be adding more of these if I can get it to work!
If these fields are blank I want it to display an error message if not I want the form to be submitted. As it is, the form is submitted when these fields are blank (not good!)
Can someone fix it?
function validateFields (aform)
{ var fieldArray = ["hospUnitNo","paedSurgeon1"];
var field = "";
var decision = true;
var prompt = "";
var i = 0;
for (i = 0; i<fieldArray.length;i++)
{
field = fieldArray[i];
if(field.value =="")
{
decision = false;
break;
}
}
if (!decision){alert(field + " is a required field. Please enter a value.");}
else { aform.submit(); prompt = "The form is being submitted.";alert(prompt);}
}
The array contains the field names in the form - I will be adding more of these if I can get it to work!
If these fields are blank I want it to display an error message if not I want the form to be submitted. As it is, the form is submitted when these fields are blank (not good!)
Can someone fix it?
function validateFields (aform)
{ var fieldArray = ["hospUnitNo","paedSurgeon1"];
var field = "";
var decision = true;
var prompt = "";
var i = 0;
for (i = 0; i<fieldArray.length;i++)
{
field = fieldArray[i];
if(field.value =="")
{
decision = false;
break;
}
}
if (!decision){alert(field + " is a required field. Please enter a value.");}
else { aform.submit(); prompt = "The form is being submitted.";alert(prompt);}
}