Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
// 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
Copy link to clipboard
Copied
// 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
Copy link to clipboard
Copied
Thanks!
I am a bit confused on what/where exactly is a focus/blur script?
Copy link to clipboard
Copied
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
Find more inspiration, events, and resources on the new Adobe Community
Explore Now