Skip to main content
Participant
December 6, 2018
Question

Float Label in pdf

  • December 6, 2018
  • 2 replies
  • 953 views

I am trying to make a float label in an iterative pdf form. I currently have this and its not working. Any ideas?

if (!event.value) {

event.value = "For Translated French";

event.target.display = display.noPrint;

} else {

event.target.display = display.visible;

}

// 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;

}

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
December 6, 2018

I recognize the second part of the code from my post on this thread (Is there a way to add instructional text to my text field that will disappear when clicked? (PDF Forms) ), but what's the first part for?

Participant
December 6, 2018

The first part is for what will fill the float label

Thom Parker
Community Expert
Community Expert
December 6, 2018

Please explain what you mean by "float label". And how this code is being used.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
December 6, 2018

A float label is a label that is in the form field that goes away once the field is fill out. ex: Float Labels with CSS | CSS-Tricks

The code is being used in acrobat for to create the float label.

Legend
December 6, 2018

People don't use float labels with PDF forms. That's not to say that you can't make something like this work, but it means you can't assume we know what you are trying and what you expect.

One key problem may be that from your incomplete example I think you may be trying to overlap visible form fields (the label and the main field). Never do that, it just won't work reliably because it is unpredictable which of the two fields gets an event.

If that ISN'T what you are doing please explain what you want to happen, how you plan to make it happen, and what actually happens. If you ARE overlapping visible fields, DON'T.