Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Loop to validate all field before sending / printing

Avatar

Former Community Member

Hi Guys,

I have try for the last two days to script a loop that can check if all field are "non null" brefore sending the form through email or before printing.

I tried to loop through the node class : exclGroup but I could not get it to work ...

Does someone have a script that loop the whole form and list the field that are empty ?

Best Regards,

Crak

2 Replies

Avatar

Former Community Member

The script, below, iterates over a subform called 'subform1' and for all objects of type 'field' it checks for null. The script was used to identify text fields. See the scripting reference for the list of containers that are of type 'field'.

// form1.subform1.replaceNullsBtn::click - (JavaScript, client)

var oNodes = subform1.nodes;

for (var i=0; i < oNodes.length; i++) {

  if (oNodes.item(i).className == "field") {

    if (oNodes.item(i).rawValue == null) {

      oNodes.item(i).rawValue = "not null";

    }

  }

}

Steve

Avatar

Former Community Member

Thank you Steve for your fast answer,

I will try today to implement your solution

Crak