Answered
I have created a PDF Form using LiveCycle Desinger 7.1.
This form has Dynamic Repeating Elements and each one will have a [+] button the add a new element, and [-] button to remove the current one.
The repeating element has Min validation value of 1.
If the user click on [-] and there is one element, he will get script error that the element cannot be deleted since the minimum is 1.
I want to write validation to check the number of elements in the repeating subform, and tried this one, but not working:
JavaScript on MoustUp Event of the [-] button:
if (this.parent.nodes.length <= 1)
{
app.alert("You cannot delete this element.")
} else {
//
// the code to delete the element is working fine.
//
}
Please help.
Tarek.
For example if the repeated subform is named "ItemDetail" then this code can be used in any element inside the subform.
_ItemDetail.count
Where the underscore is shorthand for the instance manager and "count" is the number of existing intances of that subform. This code is equivalent to:
ItemDetail.instanceManager.count
A simple way to handle the delete subform button is to place this code in the "initialize" event for the button
This code hides the delete button if there is only one instance of the "ItemDetail" subform.
Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]
The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script