4

I have created a form in Acrobat and would like to have placeholder text within each field instead of actual labels for each field.

The first approach was a script I inserted into "custom" under the "format" tab in properties. It would show for example, "first name" in a light gray. This worked great BUT when a user starts to enter information within that field the color of the font remained light gray.

The second option was to create insert scripts into the "onfocus" and "onblur" widgets and for some reason, I can't get onfocus (text color when someone starts filling in the field), and onblur (text that appears in the field when it's empty.) to show up at all. Below is the code to see what I'm using. Not sure if this is the correct forum but thought I'd give it a try here.

Script 1:

// Custom Format script for text field
if (!event.value) {
  event.value = "Instructional text goes here";
  event.target.textColor = color.ltGray;
  event.target.textSize = 10;
  event.target.display = display.noPrint;
} 

else {
  event.target.display = display.visible;
}

Script 2

// 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=="First name") {
  event.target.value = event.target.defaultValue;
  event.target.textColor = color.ltGray;
}

1 Answer 1

2

// On Focus script:

    event.target.value = "";
    event.target.textColor = color.black;

// On Blur script:

if (event.target.value=="") {
    event.target.value = "Company";
    event.target.textColor = color.gray;
}

This will work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.