Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

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

Avatar

Level 2

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.

0 Replies

Avatar

Level 4

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;

Avatar

Level 2

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

Level 4

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

Avatar

Level 7

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

Level 7

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

Level 2

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

Level 7

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