Expand my Community achievements bar.

Different validations in a print button -- Urgent !

Avatar

Former Community Member
Hi,



I've adopted the script stated in HightlightOneRequiredField.pdf so that the print button in my form can detect and prevent null field before pop up the print dialog.



However, there's an email field (in my form) with a validate event, i.e. to validate if the email address is in general format "xxx@xxx.com", which I want the same print button to check this email validation too (apart from the normal null field checking)



In other words, what I want is that the print button will check:

1) when a null field is detected, then pop up alert message and disable print and;



2) when a field with validate event scripted is detected, and if its validation is not passed, then pop up its existing validation error message, then disable print



Can someone help on this ?



Thanks in advance.



Alex
4 Replies

Avatar

Level 6
Hi Alex,



xfa.form.execValidate();



This will check all validations on your form, display the error message for each, and return true or false. True if all validations pass and false otherwise. Use this in your print button to check the validations before printing. So. . .



if (xfa.form.execValidate())

xfa.host.print(yada yada);



A word of caution though. I don't think this is fool-proof. A user can always print using the menu or a shortcut key in Acrobat/Reader, which bypasses your print button.



Hope this helps.



Jared Langdon

www.jlangdon.ca

Avatar

Former Community Member
Hi Jared Langdon



thanks a lot !!!



I'll try this now !



Alex