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

Validate Instance

Avatar

Level 7

I have in a  table row 3 reguired fields and I am using the addInstance() to add repeating subforms.

I am using a script and sucesfully I validate the the(3) required fields.

But when I add another instance script does not work.....

How I can validate  repeating fields(includes 3 required Textfields) for missing data

when the user clicks a email button?

Thanks

0 Replies

Avatar

Level 10

Hi,

I suspect that the script works for the first instance, Row1, but as soon as you add more instances, the script does not know which instance is referenced, Row1[0], Row1[1], Row1[2], etc. When using JavaScript to reference instances, you need to resolve the node of each instance.

There are some table examples here: http://www.assuredynamics.com/index.php/code-solutions/table-solutions/ If you have a look at the script that loops through the rows, you will see the loop and the xfa.resolveNode.

Hope that helps,

Niall

Avatar

Level 10

This is likely very similar to Niall's examples.

I have a Button object called 'emailBtn' and labelled 'Email'. I have an Email Submit Button called 'emailSubmitBtn' that is hidden. When you click 'emailBtn' the click event iterates over a table body row checking each 'quantity' object instance. There are two counters, one for the number of rows ('cnt') and a second to keep track of the number of populated 'quantity' instances. If the validated count equals the row count the click event on 'emailSubmitBtn' is called.

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

var cnt = form1.page1.subform2.table._row.count;

var validRowCnt = 0;

for (var i = 0; i < cnt; i++) {

  var qty = xfa.resolveNode("form1.page1.subform2.table.row[" + i + "].quantity").rawValue;

  if (qty == null || qty == 0) {

    xfa.host.messageBox("The part quantity in row " + (i+1) + " is missing.");

  }

  else {

    validRowCnt = validRowCnt + 1;

  }

}

if (validRowCnt == cnt) {

form1.page1.subform1.emailSubmitBtn.execEvent("click");

}

Steve

Avatar

Level 7

Hi Steve,

Thank you for your reply in this matter.

For some reason I can not download your attachment.

Thank you

Avatar

Level 10

Looks like the forum software is misbehaving. If you send an email to stwalker.adobe@gmail.com I will forward the form.

Steve