I'm wondering if someone can help me out. I am creating a fillable form using Adobe Acrobat 7.0 Professional.
I have already created all of the fields and have set the required fields to "required." The user will complete the form and submit the form as a pdf attachment via email.
When the user clicks the button to email the pdf I want 2 things to happen: 1. check to make sure that all of the required fields are completed and 2. lock all of the fields so that the form cannot be altered by the recipient.
I have found script that allows me to "protect" all of the fields when the "submit" button is clicked however, if a required field is incomplete the user cannot complete the field because the form is locked.
I need some kind of an "if" clause that IF all required fields are complete the form will be locked an emailed. Here is my script:
// Lock the form before attaching to email
for (var nPageCount = 0; nPageCount < xfa.host.numPages; nPageCount++) {
var oFields = xfa.layout.pageContent(nPageCount, "field");
var nNodesLength = oFields.length;
// Set the field property.
for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) {
oFields.item(nNodeCount).access = "protected";
}
}
Thank you in advance to anyone that is willing to give me some guidance.
brzap
What you need to do of course, is to test the required fields before submitting. In fact, you can use this exact same loop for the process. Just test for the "nullTest"
For example:
None of this code is tested. I just made it up. But it should do the trick.
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/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]
Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script