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

New Here ,
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";

}

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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;

TOPICS
Acrobat SDK and JavaScript, Windows

Views

222

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

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

New Here ,
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";

}

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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;

TOPICS
Acrobat SDK and JavaScript, Windows

Views

223

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
Oct 11, 2016 0
Most Valuable Participant ,
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
Reply
Loading...
Oct 11, 2016 0
New Here ,
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
Reply
Loading...
Dec 16, 2020 0
Most Valuable Participant ,
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
Reply
Loading...
Dec 16, 2020 0
New Here ,
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
Reply
Loading...
Dec 16, 2020 0
Most Valuable Participant ,
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
Reply
Loading...
Dec 16, 2020 0
Most Valuable Participant ,
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
Reply
Loading...
Dec 17, 2020 0
Adobe Community Professional ,
Dec 17, 2020

Copy link to clipboard

Copied

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
Reply
Loading...
Dec 17, 2020 0