Skip to main content
Participant
Oct 11, 2016 8:09 PM UTC
Answered

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

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

}

This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Oct 11, 2016 8:28 PM UTC

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;

7 replies

Bernd Alheit
Community Expert
Community Expert
Dec 17, 2020 2:10 PM UTC

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

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

Translate
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Oct 11, 2016 8:28 PM UTC

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
Participating Frequently
Dec 16, 2020 6:51 PM UTC

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
try67
Community Expert
Community Expert
Dec 16, 2020 8:38 PM UTC

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