We have developed required field custom validation logic, that will loop over list of required fields, one at a time, check if field is empty or null, then it will highlight the field, and raise validation error, one error for all fields that are not filled.
The problem is that the field is marked as required, and the parent subform or object is hidden, due to a bug for example.
How we can get around this issue?
One way it to display the list of empty fields in a subform along with the Required Field Validation Error.
But, how we can jump to the field (using setFocus) if the parent object is hidden?
Is there way to find out if the parent, or any ancestor is hidden, then force to make it visible?
Anyone knows if this issue has been addressed before?
I did a form that had a repeatable collapsible block (Site locations in my case), so when an error was detected I had to make the site visible before navigating to the field. The errors were in a listbox and the click code, would check for the field being visible, if not it would work up the structure looking for a script object with a makeVisible function in it. Is that like your situation?
var targetObject = xfa.resolveNode(targetSOM.value); // Use the xfa.layout.page method to determine if the field is hidden as it maybe a parent subform
// that has the presence set to "hidden".
var pageNumber = 0;
if (targetObject !== null)
if (targetObject.className === "exclGroup")
// xfa.layout.page does not work with an exclGroup object
pageNumber = xfa.layout.page(targetObject.resolveNode("#field"));
pageNumber = xfa.layout.page(targetObject);
if (pageNumber === 0)
for (var formObject = targetObject; formObject.parent !== null; formObject = formObject.parent)
var scriptObject = formObject.resolveNode("#variables.script");
if (scriptObject !== null && scriptObject.hasOwnProperty("makeVisible"))
xfa.host.currentPage = pageNumber - 1; // This stops the exit event firing on the target object
I used the xfa.layout.page() method to work out if the object was visible and "for (var formObject = targetObject; formObject.parent !== null; formObject = formObject.parent)" works its way up the structure. The makeVisible function would then call the click event on the expand/collapse button.
if (SiteHeader.Buttons.Expand.caption.value.text.value == "+")
There are probably easier ways but this was a general solution which left the hide/show logic in the object that was hidden.
I guess your best bet would be verifying each parents' visibility when focusing on an object and make sure they are visible.