Skip to main content
Participating Frequently
February 4, 2020
Answered

How do I make the default title disappear?

  • February 4, 2020
  • 2 replies
  • 2859 views

Hi Everyone,

 

Im making a text box that has a default value that "Name" and when the user clicks on the textbox the "Name" value automatically disappears and they can write whatever they want. If they click away without writing anything then "Name" appears back on to the textbox

 

I understand that it has to do with scripting and the script I have currently forces the user to manually delete the "Name" value out of the textbox

 

// Custom Format script for text field

if (!event.value) {

event.value = "Name";

event.target.display = display.noPrint;

} else {

event.target.display = display.visible;

 

}

 

How should I proceed?

This topic has been closed for replies.
Correct answer JR Boulay

// On Focus script:
if (event.target.value == event.target.defaultValue) {
event.target.value = "";
event.target.textColor = color.black;
}

 

// On Blur script:
if (event.target.value == "") {
event.target.value = event.target.defaultValue;
event.target.textColor = color.ltGray;
}

 

Don't forget to enter the default value in : Text field Properties : Options : Default value

2 replies

JR Boulay
Community Expert
Community Expert
February 4, 2020

Acrobat Pro : Prepare Form : double-clic on a field : Properties : Actions : On Focus : Run a JavaScript

Acrobat Pro : Prepare Form : double-clic on a field : Properties : Actions : On Blur : Run a JavaScript

Acrobate du PDF, InDesigner et Photoshopographe
JR Boulay
Community Expert
JR BoulayCommunity ExpertCorrect answer
Community Expert
February 4, 2020

// On Focus script:
if (event.target.value == event.target.defaultValue) {
event.target.value = "";
event.target.textColor = color.black;
}

 

// On Blur script:
if (event.target.value == "") {
event.target.value = event.target.defaultValue;
event.target.textColor = color.ltGray;
}

 

Don't forget to enter the default value in : Text field Properties : Options : Default value

Acrobate du PDF, InDesigner et Photoshopographe
Participating Frequently
February 4, 2020

Thanks!

 

I am a bit confused on what/where exactly is a focus/blur script?