Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

PrePrint

jeanette614
Level 4
Level 4

How would I script a prePrint event if I don't want a subform to print if the fields inside it are empty?

0 Replies
radzmar
Level 10
Level 10

Hi,

to prevent user from printing you can use the validate element in the config DOM.

Here's an article which descibes how to use it.

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

jeanette614
Level 4
Level 4

I don't want to restrict printing by the user unless the fields are filled, I want the subforms that have unfilled fields to not print on the document. I probably didn't explain it well.

Let me try again.... I have a form with a visible subform with fill in fields and there is a checkbox in front of the first field. If that checkbox isn't checked and the fields are empty, I don't want that subform to print. Does that make sense?

_Bruce_Robertson
Level 10
Level 10

Hi,

I use a function like the one below to test for a subform containing empty fields, so you could pass in the subform and if you get a true response set the presence property of the subform to "hidden".

function isNull(node)

{

    //Debug.trace(arguments);

    var result = true;

    switch (node.className)

    {

        case "exclGroup":

        case "field":

            result = node.isNull;

            break;

    }

    for (var i=0; i<node.nodes.length && result; i++)

    {

        var childNode = node.nodes.item(i);

        if (childNode.isContainer && childNode.className !== "draw" && childNode.className !== "variables")

        {

            result = isNull(childNode);

        }

    }

    return result

}

Depending on how complicated your subform is it might just be simplier to test the fields individually.

Bruce

gretchenhs42
Level 3
Level 3

Now, if I could get someone to take my form and show me how to do one of the subforms on it, this would be awesome!  LOL