Is there a way to change txt field background color based on user entry.

Avatar

Avatar

michelej0221

Avatar

michelej0221

michelej0221

02-07-2015

I need the background of a text field to change based on the users entry.  For example if the user enter R the background changes to red, G - the background changes to green, Y - the background changes to yellow.

Accepted Solutions (0)

Answers (7)

Answers (7)

Avatar

Avatar

jasotastic81

Avatar

jasotastic81

jasotastic81

06-07-2015

Here's a screenshot of how I set this up. The color should stay once you leave the field unless there's something else causing it to change.

786000_pastedImage_0.png

Avatar

Avatar

michelej0221

Avatar

michelej0221

michelej0221

06-07-2015

Thank you jasotastic81.  My only question is the color only  changes when I mouse click over it..  Is there a way for the color to remain once the entry is made.  R turns red and and is visible for each entry.

Avatar

Avatar

jasotastic81

Avatar

jasotastic81

jasotastic81

02-07-2015

I'm sorry, I didn't see that you asked for yellow.


if (this.rawValue == "Y" || this.rawValue == "y") this.fillColor = "255,255,0";


Avatar

Avatar

jasotastic81

Avatar

jasotastic81

jasotastic81

02-07-2015

This in the exit event will work:


if (this.rawValue == "R" || this.rawValue == "r") this.fillColor = "255,0,0";


if (this.rawValue == "G" || this.rawValue == "g") this.fillColor = "0,255,0";


if (this.rawValue == "B" || this.rawValue == "b") this.fillColor = "0,0,255";


Avatar

Avatar

try67

Avatar

try67

try67

02-07-2015

Yes, it does make quite a difference. I'll move your question to the LCD forum.

Avatar

Avatar

michelej0221

Avatar

michelej0221

michelej0221

02-07-2015

My text fields are within a table in livecycle does this make a difference.  I entered your code and it doesn't seem to be working for me.  I'm new to live cycle so I'm sure I'm doing something incorrectly

Avatar

Avatar

try67

Avatar

try67

try67

02-07-2015

Sure, you can use this code as the field's custom validation script:

if (event.value=="R") event.target.fillColor = color.red;

else if (event.value=="G") event.target.fillColor = color.green;

else if (event.value=="Y") event.target.fillColor = color.yellow;

else event.target.fillColor = color.transparent;