Skip to main content
cmvarga5
Known Participant
Apr 24, 2025 3:40 PM UTC
Question

Temporary Text (Placeholder) in Form Field

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).

4 replies

Thom Parker
Community Expert
Community Expert
Apr 24, 2025 4:00 PM UTC

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];  
}

 

 

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Nesa Nurani
Community Expert
Community Expert
Apr 24, 2025 4:11 PM UTC

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";}

 

Translate
Thom Parker
Community Expert
Community Expert
Apr 24, 2025 5:12 PM UTC

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.

 

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Legend
Apr 24, 2025 3:53 PM UTC

Hi @cmvarga5, 

 

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

 


~Tariq

Translate