Hello-
I had posted something like this prior. However the iteration for each field to be highlighted wont work as in the code it only highlights the first field that was required. How can I put each element into a variable and have the form highlight all of the fields that were required at once?
I had posted something like this prior. However the iteration for each field to be highlighted wont work as in the code it only highlights the first field that was required. How can I put each element into a variable and have the form highlight all of the fields that were required at once?
Code:
if (theForm.pr_ny_estimate.value.length < 1)
{
themessage = themessage + " - Payroll Next year estimate";
theForm.pr_ny_estimate.style.backgroundColor = "#ffff00";
}
if (theForm.pr_ly_estimate.value.length < 1)
{
themessage = themessage + " - Payroll Last year estimate";
theForm.pr_ly_estimate.style.backgroundColor = "#ffff00";
}
//alert if fields are empty and cancel form submit
if (themessage == "You are required to complete the following fields: ") {
document.form.submit();
}
else {
alert(themessage);
return false;
}
}