Skip to main content
January 28, 2011
Answered

Enforcing required text fields in pdf before saving or printing

  • January 28, 2011
  • 1 reply
  • 65671 views

Hi all,

First of all, please know that I have just spent over an hour going through as many threads as I can regarding required fields but none of them seemed to answer my question since most dealt with online forms or more complex issues.

All I am trying to find is some way of enforcing required text fields on a pdf form. There are three fields at the top of my form that need this. I would like to prevent the user from being able to save or print unless these fields are filled out.

Thank you very much in advance for your help:)

Best regards,

Christine

    This topic has been closed for replies.
    Correct answer George_Johnson

    Thank you George:) I got this to work but it isn't the exact solution I am looking for:(

    Knowing everyone over here, they will probably think that there is something wrong with the form because there are no alert messages. Is there any way to make things work so that an alert message simply pops up if they try to leave/exit a field before filling it in. I would prefer this behaviour instead of disabling some of the fields because a user may happen to click on one of those disabled fields first and then wonder why they cannot enter any information.

    Thank you so much for your help and your patience:)

    Kind regards,

    Christine


    FWIW, I've found that people quickly get used to forms that behave the way I showed, and even appreciate it since it helps reduce invalid entries, unlike what I'm about to show below...

    You could do something like the following in the On Blur event, similar to what was suggested in the article you linked to:

    // On Blur script

    if (!event.target.valueAsString) {
        app.alert("[Provide field description here] must be complete. Please enter something, anything", 3);
    }

    Note that I left out the setFocus call.

    1 reply

    Inspiring
    January 28, 2011

    You cannot prevent either. You can use the "Document Will Save" and "Document Will Print" events to alert the user (app.alert) that certain fields are not complete, but that's it.

    January 28, 2011

    Thank you:)

    Here is an alternative I would like to try to do then...perhaps force the user to fill in the field/s before being able to move on to the rest of the form.

    I found this webpage: http://cookbooks.adobe.com/post_Enforcing_Required_Fields-16435.html

    It describes how to do this by inserting javascript to the "On Blur" action of the field that is required. I am having a problem with that script tho' - I seem to get 'locked' and unable to do anything else after the alert window pops up. If I have just one required field it works fine, but I have 3 that are right underneath eachother, with a separate instance of the script being applied to each field. I tried to the variation that was supplied by another user futher down the page but am having the same issue.

    Can you give me any further advice or help regarding this? I have Acrobat 9.1.2.

    Thank you again in advance:)

    Christine

    Inspiring
    January 28, 2011

    I would not use the blur event for this, but rather the Validate event, assuming you're talking about a text field or combo box. The validate script would see if the field value is empty, and if so, set the other fields to hidden and reset their values. If the field is not empty, the other fields would be set to display.