Skip to main content
Participant
Nov 3, 2020 1:59 PM UTC
Answered

Help with Javascript for changing form field to white when text is entered

I am having trouble with my script. I can get it to change to white in the form field when I enter text as I wanted, but I can't get it to change back to transparent if no text is there or deleted. I think I need an if/then statement but I can't seem to get it worded correctly. 

Any help would be greatly appreciated.

Here is what I have so far, which works if I put it in "custom", or o"n focus":

// custom keystroke action;
FillHighlight(event.target.name, color.white);

Thank you!

This topic is closed to new replies. Start a new post to keep the conversation going.
Nesa Nurani
Nesa NuraniCorrect answer
Community Expert
Nov 3, 2020 2:13 PM UTC

Try this code:

event.target.fillColor = event.value != "" ? color.white : color.transparent;

4 replies

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
Nov 3, 2020 2:13 PM UTC

Try this code:

event.target.fillColor = event.value != "" ? color.white : color.transparent;

Translate
Erika0D44Author
Participant
Nov 3, 2020 2:18 PM UTC

THANK YOU!!

I put the code in the validate scipt option and it works like a charm! Thank you so much!

Translate
Bernd Alheit
Community Expert
Community Expert
Nov 3, 2020 2:08 PM UTC

What does you use in the function FillHighlight?

Translate
Erika0D44Author
Participant
Nov 3, 2020 2:20 PM UTC

It was the only thing I could think of....when tabbing or highlighting thru the fields, I wanted to change the fill. I know very little about Java but I knew that it had to be possible to do some kind of if/than statement to code the change. Thank you for responding to me.

Translate