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

Script to change text field's fill color depending on text not working in Adobe Reader

Community Beginner ,
Nov 24, 2022 Nov 24, 2022

Copy link to clipboard

Copied

Hi 

I prepared a document with a form text field. The custom validation script for each field is as follows: 


if (event.value=="No Stock")

event.target.fillColor = color.red;

else if (event.value=="Medium")

event.target.fillColor = color.yellow;

else if (event.value=="High")

event.target.fillColor = color.green;

else if (event.value=="")

event.target.fillColor = color.transparent;

 

Basically, it is working fine in Adobe Reader  DC Pro for me and my collegues

But in all other Adobe Reader versions (e.g. Adobe Reader DC), the coloring is not permanent only when you hover over the field and click on it you can see it.  

And I don't understand what I am doing wrong! 

Thanks already for the help and suggestions

TOPICS
Acrobat SDK and JavaScript , Windows

Views

166

Likes

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 24, 2022 Nov 24, 2022

It seems your runtimeHighlight property is set to true. You can use this script in document level:

app.runtimeHighlight = false;

or use this script:

if (app.runtimeHighlight) app.runtimeHighlight = false;
if (event.value=="No Stock") event.target.fillColor = color.red;
else if (event.value=="Medium") event.target.fillColor = color.yellow;
else if (event.value=="High") event.target.fillColor = color.green;
else event.target.fillColor = color.transparent;

 I modifyed a bit your script because what

...

Likes

Translate

Translate
Community Expert ,
Nov 24, 2022 Nov 24, 2022

Copy link to clipboard

Copied

You have fields highlight turned on.

Likes

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 24, 2022 Nov 24, 2022

Copy link to clipboard

Copied

Thank you a simple way to solve it is if I have a pool of people and can control their properties! Thanks:) 

 

Likes

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 24, 2022 Nov 24, 2022

Copy link to clipboard

Copied

It seems your runtimeHighlight property is set to true. You can use this script in document level:

app.runtimeHighlight = false;

or use this script:

if (app.runtimeHighlight) app.runtimeHighlight = false;
if (event.value=="No Stock") event.target.fillColor = color.red;
else if (event.value=="Medium") event.target.fillColor = color.yellow;
else if (event.value=="High") event.target.fillColor = color.green;
else event.target.fillColor = color.transparent;

 I modifyed a bit your script because what happens if the text is anything else???

You will maybe need to set the runtimeHighlight property to true after that (or not) !!! That can be done when you close the file for example.

app.runtimeHighlight = true;

 

Likes

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 24, 2022 Nov 24, 2022

Copy link to clipboard

Copied

Simple and nice! This works well after I set the app.runtimehighlight=true; it works strictly as intended! Thank you so much. Also, the addition makes sense; I did not think about it that someone would write anything else inside the text fields, haha! Just great! 

Likes

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 25, 2022 Nov 25, 2022

Copy link to clipboard

Copied

Be aware, though, that this changes this setting for all documents the user will open, not just for yours. It might be a good idea of informing them of that change, or (even better) to get their permission for doing it.

Likes

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 25, 2022 Nov 25, 2022

Copy link to clipboard

Copied

LATEST

ok well noted thank you! when I send it, I will inform them accordingly! 

 

Likes

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