PDA

View Full Version : Problem validating then sending a form


rbaker
05-23-2003, 06:08 PM
I am trying to validate a form, return to the form when required fields are not complete and then submit when all required fields are completed. The script below validates but returns to the form even if all required fields are filled in. It picks up all the data properly. Can anyone help?

function func_send_it()
{
return_boolean = true
obj = eval(AutReq)
for(i=0;i<obj.length;i++)
{
field_name = obj.elements[i].name;
if (field_name.indexOf("_ck") != -1)
{
if (obj.elements[i].value == "")
{
obj.elements[i].style.backgroundColor = "red";
return_boolean = false
}
else
{
obj.elements[i].style.backgroundColor = "white";
}
}
}
return return_boolean;
}


// -->


temp = "Third Judicial District" + unescape("%0D");

temp = temp + "New Automation Equipment Request" + unescape("%0D") + unescape("%0D");

temp = temp + "Fiscal Year: " + document.AutReq.FY_ck.value + unescape("%0D") + unescape("%0D");

temp = temp + "Subobject: 62121" + unescape("%0D") + unescape("%0D");

temp = temp + "Subobject Name: NRR - Automation" + unescape("%0D") + unescape("%0D");

temp = temp + "Cost Center: " + document.AutReq.CostCenter.value + unescape("%0D") + unescape("%0D");

temp = temp + "Court/Agency: " + document.AutReq.CourtAgency_ck.options[document.AutReq.CourtAgency_ck.selectedIndex].value + unescape("%0D") + unescape("%0D");

temp = temp + "Program No.: " + document.AutReq.ProgramNo.value + unescape("%0D") + unescape("%0D");


document.AutReq.body.value = temp;
document.AutReq.submit();


}

arnyinc
05-23-2003, 08:39 PM
The problem most likely lies in how you are calling your function. There are a few specific differences between a submit button and a normal button.

rbaker
05-27-2003, 04:49 PM
I found the problem. Thanks for all your help.