I want to:
- validate a AcroForm [b]before[/b] it prints (users would be using File/Print)
- [b]stop[/b] the print if it fails validation
- send an alert message on failure (each validation check sends a different message)
- allow to print if no errors & passes validation
I expect I need to place this script at the 'Doc Will Print' action. Not sure if I got the code right; I'm getting stuck at an 'invalid break' error, and I'm not 100% confident that I didn't make other mistakes in the code.
As always, your time to review this and tell me how to correct is appreciated.
There are 2 groups of fields that need to be validated:
- 1st validation: 5 text fields which all have the same Parent name: "Contact. [i]child[/i]"
- 2nd validation: 1 (group of 5) radio/checkboxes which share the same name: "Payment.Form" (each with their own respective export value)
var bSuccess=True; var emptyTest = /^\s*$/; var fieldCount = this.getField("Contact").length; var fld = 0; var pymtform = this.getField("Payment"); for (var i=0; i < fieldCount; i++); { fld = this.getField("Contact"); if(emptyTest.test(fld.value)); bSuccess=false;{ this.printDoc(false); app.alert({cMsg: "REGISTRATION FORM INCOMPLETE\n\n" + "PLEASE INPUT CONTACT INFORMATION", cTitle:"REGISTRATION FORM ERROR"}); break;{ } if(bSuccess); if (pymtform.value == "Off") { this.printDoc(false); app.alert({cMsg: "REGISTRATION FORM INCOMPLETE\n\n" + "PLEASE SELECT FORM OF PAYMENT\n\n" +"If paying by credit card, please input credit card information requested", cTitle:"REGISTRATION FORM ERROR"}); break;{ if(bSuccess) this.printDoc(true); } }
- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com