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

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

New Here ,
Oct 11, 2016 Oct 11, 2016

Copy link to clipboard

Copied

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

Views

649

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 , 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;

Likes

Translate

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

Copy link to clipboard

Copied

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;

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

Copy link to clipboard

Copied

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?

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

Copy link to clipboard

Copied

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.

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

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.

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

Copy link to clipboard

Copied

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.

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

Copy link to clipboard

Copied

LATEST

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

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

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