Skip to main content
Participant
February 21, 2017
Question

Change text box fill color if there is text is in text box

  • February 21, 2017
  • 1 reply
  • 1840 views

Hello,

I am new to pdf forms,but would like to know if the following is possible.

I have multiple text boxes in my form and have my stamped signature in textboxes.I would like to hide my signature unless I enter the date in the textbox.

I was hoping to do this by just changing the textbox color from white to transparent if there is text in textbox.When text disappears so does signature.

Maybe there is a better way to do this?

Any advise or help would be appreciated.

Thanks

Ben

This topic has been closed for replies.

1 reply

Karl Heinz  Kremer
Community Expert
Community Expert
February 21, 2017

To hide a form field, you can use the Field.display property: Acrobat DC SDK Documentation

To set it to visible, you use the following line:

this.getField("MyField").display = display.visible;

To hide the field you would use this:

this.getField("MyField").display = display.hidden;

Participant
February 21, 2017

Thanks for your help.That will hide my text that I type in textbox field,but what i want to do is hide the image behind it until I enter text in the field.The image is just a stamp I created.

Thanks

Karl Heinz  Kremer
Community Expert
Community Expert
February 21, 2017

Ah, that's different. A stamp is an annotation. You can show and hide an annotation, but you will have to find out what the annotation's internal name is. To do that, select the annotation and then run the following command in the JavaScript console:

this.selectedAnnots[0].name

If you don't know how to execute JavaScript in the JS console, review this tutorial: https://acrobatusers.com/tutorials/javascript_console

You will get something like this:

3186a7a0-f9b1-d842-a0b3-9af399cecdc4

With this information, you can now show and hide the stamp:

this.getAnnot(0, "3186a7a0-f9b1-d842-a0b3-9af399cecdc4").hidden = true;    // hides the annotation

this.getAnnot(0, "3186a7a0-f9b1-d842-a0b3-9af399cecdc4").hidden = false;    // shows the annotation

The first parameter is the page on which your stamp is - the first page is page 0, the second page of the document is page 1, and so on.