Here's a simple custom Validate script that sets the color to red if blank and white if not blank:
// Custom Validate script for text field
event.target.fillColor = event.value ? color.white : color.red;
Other field types will need different approaches. Fields can also be set to not print, so you might want to set blank field to non-printing too if you want the user to be able to print and fill by hand.
Fantastic! Thanks George, that works beautifully.
If I want to make a custom colour for the field - to match the client's brand - can that be defined?
Yes. If you know the RGB or CMYK values you can use color arrays instead of one of the predefined colors. For example:
event.target.fillColor = event.value ? color.white : ["RGB", 218/255, 25/255, 125/255];
event.target.fillColor = event.value ? color.white : ["CMYK", 0, 0.794, , 0.427, 0.145];
One more question if I can please George.
If I have mutually exclusive checkboxes - meaning only one can be checked at a time - is it possible to do something similar?
The Mouse Up script of each check box could be something like:
// Mouse up script for check box
event.target.fillColor = event.target.value !== "Off" ? color.white : color.red;
Brilliant! This is really neat stuff.
Thank you yet again George for sharing your knowledge.
Is there anything like this that works for radio buttons?
You can also create highly customized radio buttons and checkboxes with a little help from a PDF Library tool. See the example file at the link below.
Thanks for the clue. I have read through this before and now again several times. Seems the problem is more complex than this clue can help me figure out.