Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Validate Fields Before printing

Avatar

Former Community Member
Is there a way to disable printing of a form with numerous required fields until all fields have been filled in. I know that other "events" will prompt for the required fields, but for this form, it must be printed, but I want to make sure that all the required fields are completed.



Thanks

L
5 Replies

Avatar

Former Community Member
Not fully. You could put a print button on your form that does field validation and if everything passes then it calls xfa.host.print() and if not it doesn't.



But a savy user would always be able to overide this with the default print action.



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
Thanks Chris, that is what i have now: but after it displays the error validation(s) it continues on to the print dialogue. see code below:


Avatar

Former Community Member
So from the script I'm assuming that if all validations pass you want to mail the PDF and then print. If that's the case then moving the print() call into the else block that contains mailDoc() would do it.



If not, you'll still need to be put print() inside some sort of conditional statement, otherwise it will always run.



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
Perfect Chris, I removed the maildoc and put the print inside the else statement, so that now it will not print (short of the manual override) unless required fields are filled in.



Thanks for your help



Lisa

Avatar

Former Community Member
i found a super cool secret code to validate the whole form in one line of code!



F.execValidate();



so my print button is a normal button (not a print button)

with this code for onclick:



if(F.execValidate())

{

xfa.host.print(1, "0", (xfa.host.numPages - 1).toString(), 0, 1, 0, 0, 0);

}



easy as that!

IMPORTANT:

- unfortunatly it does not check if required fields are empty

- it only checks the "validation pattern" under Object > Value

- the "Error" box beside "validation pattern message" MUST be checked (if it is not checked, your validation errors will still popup, but the function will return true when it should be false - and therefore the print box will popup)