Conditional Formatting to Fill a text box color IF a different box has text
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Change this:
if (event.value= (this.getField("Text_Box_With_Text_if").valueAsString==""))
To:
if (event.value=="")
Copy link to clipboard
Copied
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=="")
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Not entirely sure what you mean, but you can set the fill color of the box as transparent. However, you can't change its opacity level, like you can with a comment. It's either transparent or it's not.
And I don't work for Adobe...
Copy link to clipboard
Copied
Or you could actually use a comment... Those can be created and edited using a script, too.
Copy link to clipboard
Copied
So I want to make it so that if this box is checked, the highlight tool shows up. Otherwise, it is not there. Where do I need to go to input the code and what is the code needed?
Copy link to clipboard
Copied
Go to CheckBox properties->Action->MouseUp->Run Javascript add this code:
if(event.target.value != "Off"){
this.getAnnot(0,"Your annot name goes here").hidden = true;}
else
this.getAnnot(0,"Your annot name goes here").hidden = false;
To find your annot name, select your annot(example: rectangle) and press CTRL+J
now in console paste this code:
this.selectedAnnots[0].name;
and press Enter to get name, now copy that name and put it into code where says "Your annot name goes here".
EDIT: I assume you want to show/hide highlight text next to checkbox?
Copy link to clipboard
Copied
If the box is checked I want the highlight to show up, if not I don't want highlight. When I paste your code into JavaScript Debugger (CTR+J on Comment > Highlighter tooled section of pdf) and press enter nothing happens.
Copy link to clipboard
Copied
Again, I want to have it so if a checkmark box is checked ("Yes") then the words on the PDF "Signature of Owner's Spouse" are highlighted yellow. If the box is not checked then no highlight. Hoping someone can give me clear steps because I don't know where to input this code.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
@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.
Copy link to clipboard
Copied
Hi, you can use this code:
if(event.value != ""){
event.target.borderColor = color.black;}
else event.target.borderColor = color.transparent;
Copy link to clipboard
Copied
"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
Copy link to clipboard
Copied
Insert code in checkbox mouseUp event
this.getField("Image2_af_image").display = event.target.value != "Off" ? display.visible : display.hidden;
Copy link to clipboard
Copied
Do I run a JavaScrpit?
Copy link to clipboard
Copied
Yes

