conditional form field fillColor vs no color

Explorer ,
Nov 29, 2019 Nov 29, 2019

Copy link to clipboard

Copied

 I have form which can be filled out manually or electronically.  One section has a comment box with multiple lines "printed" on the page.  Since I can't modify line spacing to line up with the printed lines, I would like to have a validation script to fillColor with white when an entry is made in the field (this will cover up the lines) or with no fillColor if there is no entry (which will leave the lines visible).  Or it could be phrased the other way around.  But I don't know how to write the script to describe a "no color" situation.  I found something similar on another post between two colors, but not with no color.  , but I don't know how to fix it.  .

if (event.value == "") event.trarget.fillColor = color.red;   //how do i say no color?

else event.target.fillColor = color.white;

 

TIA - Michelle

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

253

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Nov 30, 2019 Nov 30, 2019
Try this: if (event.value == "") { event.target.fillColor = color.transparent; event.target.strokeColor = color.transparent; } else { event.target.fillColor = color.white; event.target.strokeColor = color.gray; }

Likes

translate

Translate

Translate
Adobe Community Professional ,
Nov 30, 2019 Nov 30, 2019

Copy link to clipboard

Copied

Use: color.transparent

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 30, 2019 Nov 30, 2019

Copy link to clipboard

Copied

Ahhaaa, that's the trick!  Works perfectly.  One more question if I may.............if I want to combine a border color along with the fill color condition, how would i write that?   if value  is blank then fill and border is transparent, else fill is white and border is gray - something like this?

if (event.value == "")  {event.target.fillColor = color.transparent && event.target.borderColor = color.transparent};  

else {event.target.fillColor = color.white && event.target.borderColor = color.gray};

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 30, 2019 Nov 30, 2019

Copy link to clipboard

Copied

Try this:

if (event.value == "")  {
  event.target.fillColor = color.transparent;
  event.target.strokeColor = color.transparent;
} else {
  event.target.fillColor = color.white;
  event.target.strokeColor = color.gray;
}

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 30, 2019 Nov 30, 2019

Copy link to clipboard

Copied

Another perfect answer!  Thank you so much. 

Is there a list somewhere of what the JavaScript name is for fields in Acrobat.  NEVER would have thought of "stroke" to mean border!

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 30, 2019 Nov 30, 2019

Copy link to clipboard

Copied

The methods and properties are listed in the Acrobat Javascript reference.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines