Skip to main content
Participating Frequently
July 30, 2024
Answered

Delete default value of text field when clicked

  • July 30, 2024
  • 1 reply
  • 2387 views

hello everyone,

I have several fields in a PDF form with the following function:

 

 

if(event.value == "")
{
    event.value = "Company Name";
    event.target.display = display.noPrint;
}
else
    event.target.display = display.visible;

 

 

If the default value is not changed, then the text is not printed and that works as intended.

 

Now I want to make the fields a bit more user-friendly by removing the default text when clicking or tabbing, so that the user can enter their text directly without having to delete the default text beforehand. If they don't enter any new text or click on another field, the default text should appear again. Has anyone here had a similar case?

 

Many thanks in advance

Correct answer PDF Automation Station

There's nothing in the answer that is marked correct in that link about changing the text color.  Make sure it is entered as a custom format script.


It's not a validation script.  It's a Format script.  Remove the validation script and enter this format script:

if (!event.value) {

event.value = "Instructional text goes here";

event.target.display = display.noPrint;

} else {

event.target.display = display.visible;

}

 

1 reply

try67
Adobe Expert
July 30, 2024
DimiDNPAuthor
Participating Frequently
July 30, 2024

Thank you, but this just changes the text color.

It would be better if the text was removed and not just the color of the text was changed. The background color of each field is a light gray. If nothing is entered in the fields, you will see where you need to fill something in on the printed document.

PDF Automation Station
Adobe Expert
July 30, 2024

There's nothing in the answer that is marked correct in that link about changing the text color.  Make sure it is entered as a custom format script.