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

How do you highlight a field if it's empty?

New Here ,
Oct 11, 2016 Oct 11, 2016

I want to highlight or color a field when it's empty, how do you do it?

I've been trying out this formula but I think it's not correct because there's a Syntax Error:

var a1 = this.getField("FirstN");

if (a1.value == null)

{

a1.style.backgroundColor = "yellow";

}

TOPICS
Acrobat SDK and JavaScript , Windows
2.9K
Translate
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 , Oct 11, 2016 Oct 11, 2016

You have quite a lot of errors there... Try this code (as the field's custom validation script):

event.target.fillColor = (event.value=="") ? color.yellow : color.transparent;

Translate
Community Expert ,
Oct 11, 2016 Oct 11, 2016

You have quite a lot of errors there... Try this code (as the field's custom validation script):

event.target.fillColor = (event.value=="") ? color.yellow : color.transparent;

Translate
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
New Here ,
Dec 16, 2020 Dec 16, 2020

This works great in Acrobat Pro, but the field colors won't change in Acrobat reader which is were most users fill out the form. Is there a way to code this in Pro so that the field colors will change in Acrobat reader?

Translate
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 ,
Dec 16, 2020 Dec 16, 2020

It will work exactly the same in Reader. If you don't see it working then make sure to disable the fields highlighting in the application.

Translate
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
New Here ,
Dec 16, 2020 Dec 16, 2020

I have disabled the highlighting fields on my desktop in Acrobat pro and I have saved the file. It works great on my desktop. All the empty fields appear yellow until they are filled in and then they turn transparent. But when I open the file in acrobat reader on my android phone or my ipad all the empty fields appear yellow, and when I enter info into the field they stay yellow and I want them to turn transparent.  I cannot see anywhere to turn off field highlighting on my android or ipad. Any suggestions? Thanks

Translate
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 ,
Dec 16, 2020 Dec 16, 2020

You didn't mention this was on a mobile device... I'm not sure you can turn it off there, and even if you did it's not likely that a script will work there, I'm afraid.

Translate
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
LEGEND ,
Dec 17, 2020 Dec 17, 2020

Field highlighting is a personal preference, for your device only. It doesn't affect what others see, so you need to test both with and without.

Translate
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 ,
Dec 17, 2020 Dec 17, 2020
LATEST

Not all is possible in Acrobat Reader for iOS or Android:

https://www.adobe.com/devnet-docs/acrobatetk/tools/Mobile/iosapi/index.html 

Translate
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