Copy link to clipboard
Copied
Hello,
I am working on a form and my client has requested that when the user has enter information in the text box that it becomes highlighted. If the user doesn't enter any information the text box stays white
Copy link to clipboard
Copied
You can do it, but it will only change the fill color once you exit the field, not while you're tying in it.
To achieve it use the following as the field's custom Validation script:
event.target.fillColor = event.value.length==0 ? color.transparent : color.yellow;
Copy link to clipboard
Copied
As 'Validation' script of that field use this:
event.target.fillColor = event.value == "" ? color.white : color.blue;
Change color.blue to the color you wish field to be highlighted, note that you can use RGB colors too, for example:
color orange would be - ["RGB", 255/255, 165/255, 0/255]
If you have fields highlight turned on in your preferences you won't be able to see colors when they change, you will need to turn highlight off under preferences-> forms-> uncheck 'Show border hover color for fields'.
Copy link to clipboard
Copied
just a quick question because I am not the best at writing code in between the quotation marks is that where I place the name of text box so example
event.target.fillColor = event.value == "textbox1" ? color.white : color.blue;
Copy link to clipboard
Copied
The double quotation marks are indicating the field being blank. The code is saying, "when the value of the textbox is blank (""), the color will be white, otherwise the color will be blue (or yellow, or whatever you choose)."
As long as you enter the code into the Custom Validation script area of the textbox itself, you don't actually have to name the field (that is what 'event.target' does for you). You can use the code exactly as @try67 or @Nesa Nurani provided it, changing only the color, if desired.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now