Skip to main content
Participant
April 11, 2024
Answered

How can I get the font colour in a text box to change when I start typing?

  • April 11, 2024
  • 1 reply
  • 938 views

So I have a text box that has a default value displayed and I have made the font grey, so that when it is printed, you can write over the top of the default value easily to fill it in by hand. Aside from being a printable form to be filled in by hand, I also want to be able to fill in the form electronically, however, when I type into the text box and the default value disappears (I have used a JavaScript format for that, see below) the text that is typed into the box is still grey, I want the text to turn black when I begin typing into the field. How can I do this? I'm thinking probably an addition to the JavaScript, but my grasp of it is very limited.

 

The JavaScript format I have used is:

 

if (event.value == "") {
        event.target.display = display.visible;
        event.value = 'DDMMYY';
    }

This topic has been closed for replies.
Correct answer try67

You will need to use the On Focus event for this. Here's an example:

event.target.textColor = color.black;

 

PS. In the future you should post under the Acrobat forum if you have questions about creating form fields and using scripts. The Reader forum is about viewing PDF files in Reader.

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
April 11, 2024

You will need to use the On Focus event for this. Here's an example:

event.target.textColor = color.black;

 

PS. In the future you should post under the Acrobat forum if you have questions about creating form fields and using scripts. The Reader forum is about viewing PDF files in Reader.

Participant
April 12, 2024

Excellent, thank you!