Skip to main content
Participating Frequently
August 28, 2020
Question

Conditional Formatting to Fill a text box color IF a different box has text

  • August 28, 2020
  • 2 replies
  • 2693 views

I want to make a box colored yellow to highlight a signature on a page if there is text in another box on that same page. 

I have put this code in the Text Field Properties > Validate > Run custom validation script

if (event.value= (this.getField("Text_Box_With_Text_if").valueAsString=="")) event.target.fillColor = color.yellow;

else event.target.fillColor = color.transparent;

 

I have the Border color and fill color set to "No Color" in the appearance tab.

What is going wrong?

Thanks in advance.

This topic has been closed for replies.

2 replies

Joe5CBEAuthor
Participating Frequently
August 31, 2020

@try67

What would be the coding for if the current text field has text then change the border color to black.

Else border is transparent.

Nesa Nurani
Community Expert
Community Expert
August 31, 2020

Hi, you can use this code:

if(event.value != ""){
event.target.borderColor = color.black;}
else event.target.borderColor = color.transparent;

Joe5CBEAuthor
Participating Frequently
September 1, 2020

"Hi, you could achive this if you replace text box with image field and input photo with desired opacity, and use script in another field to show/hide image field." 

If I wanted to do this and hide/show an image field based on if a checkmark box is checked what would the code be and where would I insert it?

 

Likes

 
try67
Community Expert
Community Expert
August 28, 2020

Change this:

if (event.value= (this.getField("Text_Box_With_Text_if").valueAsString==""))

To:

if (event.value=="")

try67
Community Expert
Community Expert
August 28, 2020

Or, if you want it to be based on another field's value, then change that line to:

if (this.getField("Text_Box_With_Text_if").valueAsString=="")

Joe5CBEAuthor
Participating Frequently
August 28, 2020

Thank You! (I'm using your code from previous posts and I want you to know that I don't think Adobe is paying you enough for your work)

Is there also a way to layer words on a PDF over the colored box so that it acts as a highlighter for words and the box with the code behind the words? Right now if I have a highlighted box it will go over anything on the PDF. I want it to act like the highlighter tool in the comment tool section but to have the conditional formatting.