Skip navigation
SpammyNicholas
Currently Being Moderated

LiveCycle Newbie: Validate Before Printing Form

May 5, 2010 10:12 AM

I have a form created in Adobe Acrobat Pro that I have brought into LiveCycle to add print and emails buttons to. However, I need a specific functionality added to the standard "Print" button. It is a legal form that has required fields and the client needs to fill in all the required fields on the form BEFORE printing and signing it. We have had problems in the past with clients not filling in all the required fields before sending it back to them. So, I need to somehow make the print button check to make sure all the required fields are filled in and send a warning message and/or prevent printing if all the required fields are not filled in. Is there a way to do this?

 

I am using LiveCycle Designer ES 8.2 and I am VERY new to this program so the simpler the solution the better.

 

Thanks in advance for the help!

 
Replies
  • Currently Being Moderated
    May 5, 2010 1:46 PM   in reply to SpammyNicholas

    Hi

     

    I would add another fake print button over the top of the existing one but just add a standard button not a print button.

     

    then to the click scripting event in the script editor add something like the below

     

    if ((TextField1.rawValue == null) or (TextField2.rawValue == null) & (CheckBox1.rawValue == "1")) then

    xfa.host.messageBox("You must enter the required data to be able to print this form")

    else

    PrintButton1.execEvent("click")

    endif

     

    as you are relatively new to this. Incase the above it giberish to you I will try to explain what the above is doing.

     

    the above is an if statement using formcalc (which is the default on button objects)

     

    as this code is inserted in to the click event  (you can see what event you are looking from the dropdown at the top left of the script editor window.... make sure click is selected, and formcalc is set in the drop down to the right of the script editor window.

     

    each bracketed command e.g. (TextField1.rawValue == null) is address a single field in your form. You will need to make sure you adjust these names and the path to these names so it may end up looking like (Form1.subform.TextField1.rawValue == null).

     

    A quick tip to ensure you have the right path is with the cursor in the script window move your mouse over the field you wish to address, hold Ctrl button and click the field. This will load the field path in to the script editor and all you have to add is the .rawValue portion of the command.

     

    You require '==' because means 'is equals to' in formcalc

     

    the null term means 'if the field is empty'

     

    if you have checkboxes that require to be ticked you must address them and look for a value of 1 (as in the example) as as default when a checkbox is selected it has a value of 1.

     

    you can use or commands or & commands between expressions.

     

    please note all the comments together require brackets round them hence the double brackets at the start and end of the expression.

     

    once you have added all the required expressions to the top line

     

    the second line is saying if the statement returns a true value  e.g. in our example a true value would be returned if TextField1 or TextField2 empty AND the checkBox1 is not ticked

    then this will pop up a message box saying you have not entered the required fields to print this form

     

    then the else statement says to click the print button for the user.... which will print the form as the print button does now.

     

    I know it may seem complicated but it honestly is not that difficult.

     

    Feel free to come back to me if you need any further help.

     

    Regards

    Graham

     
    |
    Mark as:
  • Currently Being Moderated
    May 6, 2010 5:10 AM   in reply to SpammyNicholas

    Hi There

     

    If you want to send me your form  I will take a look at the code, as it is

    difficult to see any issue without the fields there etc.

     

    email it to washydraulics@hotmail.co.uk

     

    If you have any questions please don't hesitate to contact me.

    Kind Regards

    Graham Spaull

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 25, 2010 5:12 PM   in reply to DubDubDubDesigns

    Great tip, Graham.  I'm using your script to accomplish the same objective.  Works like a charm.

     

    Dave

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 22, 2010 3:37 PM   in reply to djburch

    Hi,

    I am trying to set my pdf form to not print unless all require fields are filled out, but I am having no such success.  I've tired what is listed above, but was unable to get it to work.

    Your help would be greatly appreciated!

     

    Jen

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 23, 2010 8:12 AM   in reply to JRicciuti11

    I will be out of the office starting  22/12/2010 and will not return until

    04/01/2011.

     

    Our offices are closed between Christmas and New Year.  Have a Merry Christmas

    and a Happy New Year.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 4, 2011 2:05 AM   in reply to JRicciuti11

    Hi Jen

     

    I would try something simple in the print button such as:

     

    if (form1.execValidate()){

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

    }

     

     

    Then set all the fields you need filling out as required fields.

     

    Hope this helps

     

    Graham

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 4, 2011 10:29 AM   in reply to DubDubDubDesigns

    Thanks Graham.  I have added the script recommended and the print button is now not working at all.  Any other suggestion?  Your help is greatly appreciated!

     

    Thanks you,

     

    Jen Ricciuti |  Coordinator, Safety Services

    (403) 234-6296 (|   jennifer.ricciuti@sjrb.ca

     

    ACCOUNTABLE    BALANCE    CUSTOMER FOCUSED    INTEGRITY    LOYALTY    POSITIVE, CAN DO ATTITUDE    TEAM PLAYER

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 5, 2011 2:01 AM   in reply to JRicciuti11

    Hi Jen

     

    It may be easier to send me the form.

     

    gspaull@moog.com

     

    Please include in your email the field you wish to be mandatory.

     

    ...... one last thing to make sure before you send the form, make sure the

    script language for the script I gave you yesterday is set to Javascript,

    and the form is set to a dynamic form

     

    Regards

     

    Graham

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 22, 2012 9:56 AM   in reply to DubDubDubDesigns

    Graham,

     

    I've only got 1 area, a drop down box, that is required.  I think I've got the script correct (preferences are set to Formcalc and dynamic, formcalc is selected in the scripting area of the form)

     

     

    TopmostSubform.Page1.PrintButton1::click - (FormCalc, client)

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

     

    if (DropDownList1.rawValue == null) then

     

    xfa.host.messageBox("You must choose an academic area to be able to print this form")

     

    else

     

    PrintButton1.execEvent("click")

     

    endif

     

     

    But it doesn't work.  I wonder . . . why did you suggest WAAAYYY up to (5/5/2010) that another button be placed on top of the print button.  I didn't do this because I just don't get why the script can't be applied to the standard print button.  I guess this is my problem.  Can you explain why the extra button and/or, do you see any reason in the above script why it shouldn't work?

     

    Thanks!

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 23, 2012 8:22 AM   in reply to milly mac

    Hi

     

    I have now created a form for this example as the best way to explain to people.

     

    You are correct you can do it within the same button (my knowledge and skills have developed somewhat since the orignal post)

     

    Here is a link to the page where the example can be found.

     

    http://www.dubdubdubdesigns.co.uk/livecycle/formprinting.html

     

    If you have any questions just ask

     

    Regards

     

    Graahm

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 23, 2012 9:40 AM   in reply to DubDubDubDesigns

    Great!  Thanks so much, I really appreciate your help with this!

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 23, 2012 7:31 AM   in reply to DubDubDubDesigns

    Graahm,

     

    Thanks for your example.  It has helped me tremendously!

     

    I do have a question though.  How would you use method 1 to Validate more than one field.  I have a document that has multiple fields that need to be validate before printing ans am not quite sure how to apply yor code to this.

     

    Thanks for you help!

     

    Shane

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 23, 2012 10:22 PM   in reply to Argonous

    Hi,

     

    check this article.

    It explains to prevent printing a form when any mandatory field is empty.

    http://forms.stefcameron.com/2008/04/13/prevent-printing-pdf-forms-in- acrobat-8/

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 26, 2013 4:50 AM   in reply to SpammyNicholas

    I haved a similar problem, but with a checkbox which I think is a little trickier.

    Is there a way to:

     

    1. set a print button access as readOnly by default?
    2. change it as the checkboxA gets flagged (and make it readOnly again should it get deflagged)?

     

    I tried various solutions but the closest to an acceptable one is that I get the printbutton locked on readOnly ONLY after an initial flagging/deflagging of the checkbox: so if the form is left blank, I'm still able to print through the printbutton, which is what I'd like to prevent user from.

     

    Any working help?

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 26, 2013 10:11 AM   in reply to frons79AN

    Hi

     

    There are a few ways to do this.

     

    You can do it on the click activity of the button itself to check if the checkbox is ticked e.g.

     

    form1.#subform[0].PrintButton1::click - (JavaScript, client)

     

    if ( CheckBox1.rawValue == "1" )

    {

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

    }

    else

    {

    xfa.host.messageBox("You Must Check The Box To Print This Form");

    }

     

    Or you can set the print button as readOnly when it is initialised

     

    form1.#subform[0].PrintButton1::initialize - (JavaScript, client)

    this.access = "readOnly";


    Then use the mouseUp event on the checkbox to check its value and set the button to active if its checked.

     

    form1.#subform[0].CheckBox1::mouseUp - (JavaScript, client)

     

    if (this.rawValue == "1")

    {

    PrintButton1.access = "open";

    }

    else

    {

    PrintButton1.access = "readOnly";

    }


    Or you could simply set the print button's visibility to Invisible as default and have the checkbox change the presence of the button if it is checked.

     

    form1.#subform[0].CheckBox1::mouseUp - (JavaScript, client)

     

    if (this.rawValue == "1")

    {

    PrintButton1.presence = "visible";

    }

    else

    {

    PrintButton1.presence = "hidden";

    }

     

    I have uploaded an example of all 3 methods in a single form here

     

    http://www.dubdubdubdesigns.co.uk/livecycle/examples/printbuttonActiva tionMethods.pdf

     

    Hope This Helps

     

    Regards

    Graham

    DubDubDubDesigns.co.uk

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 26, 2013 1:12 PM   in reply to DubDubDubDesigns.co.uk

    I'm an idiot: that was almost the same code I already had but of course it wasn't working because I mistyped the Javascript, a very rookie-like error:

     

    this.access == "readOnly";


    Of course it wasn't working...

     

    Anyway thank you Graham, I found very interesting the three way methods you submitted!

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (2)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points