Skip to main content
cmvarga5
Known Participant
May 16, 2025
Answered

Temporary (Placeholder) Text in Form Field but for Numbers only

  • May 16, 2025
  • 2 replies
  • 886 views

I have this script:

 

if (!event.value) {

event.value = “Enter message here”;

event.target.display = display.noPrint;

} else {

event.target.display = “display.visible;

}

 

How can I use it for numerical format only?

Correct answer PDF Automation Station

Enter the following scripts:

Custom Format:

AFNumber_Format(2,0,0,0,"",true);
if (!event.value)
{event.value = "Enter message here";}

 

Custom Keystroke:

AFNumber_Keystroke(2,0,0,0,"",true);

 

Custom Calculation:

if(!event.value)
{event.target.display = display.noPrint;}
else
{event.target.display = display.visible;}

 

Your script has curly quotes and a curly quote in front of display.visible.  Make sure you use a plain text editor like Notepad to write your scripts.

2 replies

PDF Automation Station
Community Expert
Community Expert
May 16, 2025

Enter the following scripts:

Custom Format:

AFNumber_Format(2,0,0,0,"",true);
if (!event.value)
{event.value = "Enter message here";}

 

Custom Keystroke:

AFNumber_Keystroke(2,0,0,0,"",true);

 

Custom Calculation:

if(!event.value)
{event.target.display = display.noPrint;}
else
{event.target.display = display.visible;}

 

Your script has curly quotes and a curly quote in front of display.visible.  Make sure you use a plain text editor like Notepad to write your scripts.

Nesa Nurani
Community Expert
Community Expert
May 16, 2025

@PDF Automation Station Nicely handled.
Just a tip, when using AFN you can place script in function in document level and then call it from keystroke, that way script won't disappear.

PDF Automation Station
Community Expert
Community Expert
May 17, 2025

Perfect.  Thank you @Nesa Nurani .  I'm always learning from you.

Nesa Nurani
Community Expert
Community Expert
May 16, 2025

If the field is formatted as number you can't have a placeholder message, you can use tooltip or workaround by using two fields.

cmvarga5
cmvarga5Author
Known Participant
May 16, 2025

Ok thank you!