How to get fillable PDF to prompt for required fields when user saves?

kmcamara picture kmcamara · Sep 21, 2012 · Viewed 11.6k times · Source

I've created a fillable PDF form using Acrobat 10. I see where you can set form fields to be required, but all that does is outline the fields in red.

How can I get a prompt asking users to enter data in the required fields when they hit save?

Answer

yms picture yms · Sep 21, 2012

You need to use Adobe-JavaScript if you want to achieve this.

Read this page in the Adobe documentation for more details:

Enforcing Required Fields

From that page, the code you have to include in your PDF file will look like this:

f = getField(event.target.name)
if (f.value.length == 0)
{    
   f.setFocus()    
   //Optional Message - Comment out the next line to remove
   app.alert("This field is required. Please enter a value.")
}

More details about the pop-up alert can be found here: https://acrobatusers.com/tutorials/popup_windows_part1