Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

conditional form field fillColor vs no color

Participant ,
Nov 29, 2019 Nov 29, 2019

 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
892
Translate
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

Community Expert , 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;
}
Translate
Community Expert ,
Nov 30, 2019 Nov 30, 2019

Use: color.transparent

Translate
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
Participant ,
Nov 30, 2019 Nov 30, 2019

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

Translate
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
Community Expert ,
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;
}
Translate
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
Participant ,
Nov 30, 2019 Nov 30, 2019

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!

Translate
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
Community Expert ,
Nov 30, 2019 Nov 30, 2019
LATEST

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

Translate
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