Skip to main content
Known Participant
November 29, 2019
Answered

conditional form field fillColor vs no color

  • November 29, 2019
  • 1 reply
  • 950 views

 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

This topic has been closed for replies.
Correct answer Bernd Alheit

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

1 reply

Bernd Alheit
Community Expert
Community Expert
November 30, 2019

Use: color.transparent

Known Participant
November 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};

Bernd Alheit
Community Expert
Bernd AlheitCommunity ExpertCorrect answer
Community Expert
November 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;
}