Copy link to clipboard
Copied
I have form which can be filled out manually or electronically. One section has a comment box with multiple lines "printed" on the page. Since I can't modify line spacing to line up with the printed lines, I would like to have a validation script to fillColor with white when an entry is made in the field (this will cover up the lines) or with no fillColor if there is no entry (which will leave the lines visible). Or it could be phrased the other way around. But I don't know how to write the script to describe a "no color" situation. I found something similar on another post between two colors, but not with no color. , but I don't know how to fix it. .
if (event.value == "") event.trarget.fillColor = color.red; //how do i say no color?
else event.target.fillColor = color.white;
TIA - Michelle
Try this:
if (event.value == "") {
event.target.fillColor = color.transparent;
event.target.strokeColor = color.transparent;
} else {
event.target.fillColor = color.white;
event.target.strokeColor = color.gray;
}
Copy link to clipboard
Copied
Use: color.transparent
Copy link to clipboard
Copied
Ahhaaa, that's the trick! Works perfectly. One more question if I may.............if I want to combine a border color along with the fill color condition, how would i write that? if value is blank then fill and border is transparent, else fill is white and border is gray - something like this?
if (event.value == "") {event.target.fillColor = color.transparent && event.target.borderColor = color.transparent};
else {event.target.fillColor = color.white && event.target.borderColor = color.gray};
Copy link to clipboard
Copied
Try this:
if (event.value == "") {
event.target.fillColor = color.transparent;
event.target.strokeColor = color.transparent;
} else {
event.target.fillColor = color.white;
event.target.strokeColor = color.gray;
}
Copy link to clipboard
Copied
Another perfect answer! Thank you so much.
Is there a list somewhere of what the JavaScript name is for fields in Acrobat. NEVER would have thought of "stroke" to mean border!
Copy link to clipboard
Copied
The methods and properties are listed in the Acrobat Javascript reference.