Hello all -
I'm trying to adapt Stefan Cameron's "Process All Fields" script (found here: http://forms.stefcameron.com/2006/06/26/process-all-fields/) to validate only VISIBLE fields on the form, instead of all fields, prior to submitting.
He includes a sample script that searches a form for non-filled (empty) mandatory fields when the Submit button is clicked. If such fields are found, they'll be highlighted and an error message will be displayed. Otherwise, the Email Submit dialog will open.
His sample works like a charm EXCEPT when fields are wrapped in a subform and the subform presence property is set to "invisible". His script still flags the non-filled mandatory fields even though they are not displayed or visible on the form. I'm using subforms to hide or show fields based on user interaction, so I can't just make the fields optional. If they are visible, they are mandatory.
Unfortunately, I haven't had much luck. Is there a way to flag only the visible non-filled mandatory fields?
function isVisible(oFld)
{
var bVis = true;
var nxtFld = oFld;
while(nxtFld.name != "form")
{
if(nxtFld.presence != "visible")
{
bVis = false;
break;
}
nxtFld = nxtFld.parent;
}
return bVis;
}
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script