3

I've created a form using Adobe Acrobat Pro. I would like the Date field (the first text field on the form) to be pre-filled with instructional text like "Enter date". On clicking, this should vanish and, furthermore, if the form is printed, the pre-filled text should not show.

I found a script on an acrobat site which I used in the Date field, but its not working. The script is as follows -

if (!event.value) {
event.value = "Instructional text goes here";
event.target.display = display.noPrint;
} else {
event.target.display = display.visible;
}

The in-built javascript debugger gives me the following error message:

InvalidSetError: Set not possible, invalid or unknown.
Event.value:2:Field Date:Mouse Up

Any help would be greatly appreciated, Thanks!

makmom
  • 131
  • 2

1 Answers1

0

That script is designed as a custom Format script for a text field. I know because I wrote it. It can't work in the Mouse Up event of a field. You could extend it so it behaves the same as a field with a date format setting, but you'd also have to set up a custom Keystroke script. Post again if you need help with that.

  • Hi George -- Thank you for responding, and thank you for sharing that script. I work with Acrobat X Pro, and am really stumped by how to get javascript to work in it for forms. I have been placing the script in the Actions tab. Where are you suggesting that it be placed? I also have read that browser support for javascript in acrobat forms is very inconsistent; is that correct? I come across other scripts all the time, but am obviously not placing them in the right place. – makmom Sep 30 '16 at 17:47
  • You would add the script as a custom Format script. You'll see where when you select the Format tab of the field properties window and select a format category of Custom. – George Johnson Oct 01 '16 at 20:45
  • Regarding support for JavaScript in PDFs in browsers, Chrome is the best, but it's not as complete as Adobe Reader/Acrobat. Other browsers such as Firefox and MS Edge have no support at all. If you use a lot of JavaScript, advise your users to open the document directly in Reader. Other PDF viewers have good support for JavaScript, including Foxit Reader and PDF Expert on iOS. – George Johnson Oct 01 '16 at 20:49