• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Community Beginner ,
Nov 03, 2020 Nov 03, 2020

Copy link to clipboard

Copied

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!

TOPICS
Acrobat SDK and JavaScript

Views

462

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 03, 2020 Nov 03, 2020

Try this code:

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

Votes

Translate

Translate
Community Expert ,
Nov 03, 2020 Nov 03, 2020

Copy link to clipboard

Copied

What does you use in the function FillHighlight?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 03, 2020 Nov 03, 2020

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 03, 2020 Nov 03, 2020

Copy link to clipboard

Copied

Try this code:

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 03, 2020 Nov 03, 2020

Copy link to clipboard

Copied

THANK YOU!!

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines