Skip to main content
cmvarga5
Known Participant
April 24, 2025
Question

Temporary Text (Placeholder) in Form Field

  • April 24, 2025
  • 2 replies
  • 482 views

I need to put an instruction in a text field that is only visible to the applicant. It can't be printed and can be typed over with text (that can be printed).

2 replies

Thom Parker
Community Expert
Community Expert
April 24, 2025

Tooltips are the standard method of giving the user instructions on using a field, but it can also be done by using the Format script to display text in the field itself. 

 

Like this:

if(event.value == ""){
// Field is empty, add grey non-printable instuction text.
   event.value = "Enter Data Here";
   event.target.display = display.noPrint;
   event.target.textColor = ["G",.5];  
}
else{
// Real entered value, restore field properties
   event.target.display = display.visible;
   event.target.textColor = ["G",1];  
}

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Nesa Nurani
Community Expert
Community Expert
April 24, 2025

There's a minor issue — color value 1 corresponds to white. You should use 0 instead, or better yet, use color.black for clarity and consistency.
EDIT:
I prefer using On Focus and On Blur actions for managing placeholder behavior. The main limitation with a custom format script is that the placeholder styling (such as gray text) remains visible even as the user begins typing, which can be confusing or visually inconsistent.
On Focus:

if (event.target.value === "Instruction text goes here") {
 event.target.value = "";
 event.target.textColor = color.black;
 event.target.display = display.visible;}

On Blur:

if(!event.target.value){
 event.target.display = display.noPrint;
 event.target.textColor = ["G", 0.6];
 event.target.value = "Instruction text goes here";}

 

Thom Parker
Community Expert
Community Expert
April 24, 2025

But then the instruction text is only visible when the cursor is moved over the field, which is little better than the tooltip. The idea with the format script is that the text is alway visible.

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Legend
April 24, 2025

Hi @cmvarga5

 

Thank you for reaching out. When you place a form field, choose Properties and add a Tooltip 

 


~Tariq