Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Loop through list of required fields then highlight/set focus


Level 3

Yet another one that should be straightforward but is giving me a headache!

I've set a validateForm.checkForm function on a button (not a submit button) where I'm sending in the form -



Within the checkForm function I'm doing the following initial steps:



    var myForm = completedForm.nameOfTopForm.nameOfSubformThatHoldsEverything;


    var firstSubformName = myForm.nameOfFirstSubform;

If the firstSubformName is visible, I then check the value of the field inside it:


if (ddlUnderFirstSubform.rawValue == 1) // not selected


    // do stuff


Originally I was simply highlighting each required field in turn by doing:


This worked fine.

But then I wanted to keep a list of all the errors & highlight/setFocus to all at the same time, so:

var reqFieldsList = new String(); // set as global var

if (reqFieldsList == ""){reqFieldsList = reqFieldsList + ddlUnderFirstSubform;}

else{reqFieldsList = reqFieldsList + ',' + ddlUnderFirstSubform;}

When I've been through the whole form & try the following it doesn't work:



(reqFieldsList != "")    var reqFields = reqFieldsList.split(',');    var firstField = reqFields[0];    highlightErrors(firstField);'A message', 'Title for box', 0, 0);

ddlUnderFirstSubform = firstSubformName.nameOfDropdown;;


app.alert on the firstField in both the original method & new list method shows that ddlUnderFirstSubform is [object XFAObject], but one method wors the other doesn't - any ideas?

Apologies for the long-winded message - by the way, I'm not using the in-built LiveCycle required unctionality but merely going through all fields that I know are mandatory.


1 Reply


Level 3

It's ok - I've sorted it!

Turns out that as my reqFieldsList was a string, the objects saved in there that I was trying to reference would have been strings, hence none of the commands I set for them would work.

I have now created an array - var reqFieldsArr = new Array();

Pushed each required field object into it - reqFieldsArr.push(requiredFieldObject);

Then looped through them at the end -


(reqFieldsArr != null)


    var counter = reqFieldsArr.length;

    var firstField;

    for (var f=0; f<counter; f++)



          if (f == 0)


= reqFieldsArr[f];}

    }'A number of mandatory fields have not been completed. Please check through the form and complete the highlighted fields');;

    return false;




return true;}

Might help someone else.....