Copy link to clipboard
Copied
I am trying to change the color of the text based on what the text field ends with.
For example:
"Rewards Price $9.96" - Orange
"Sale Price 9.97" - Red
If the text box ends in .96 it automatically turns the text orange, but if it ends in anything else it ends in red.
Is this possible?
Copy link to clipboard
Copied
Sure. You can use something like this as the field's custom validation script to achieve it:
if (/\.96$/.test(event.value)) event.target.textColor = ["RGB", 1, 0.66, 0];
else event.target.textColor = ["RGB", 1, 0, 0];
Edit: fixed code.
Copy link to clipboard
Copied
Sure. You can use something like this as the field's custom validation script to achieve it:
if (/\.96$/.test(event.value)) event.target.textColor = ["RGB", 1, 0.66, 0];
else event.target.textColor = ["RGB", 1, 0, 0];
Edit: fixed code.
Copy link to clipboard
Copied
I pasted the code, adjusted to color to CMYK and added the colors needed, but the text turned black and doesn't change at all...
if (/\.96/.test(event.value)) event.target.textColor = ["CMYK", 12, 60, 98, 1];
else event.target.textColor = ["CMYK", 18, 92, 100, 8];
Copy link to clipboard
Copied
You should not change code unless you know what you're doing... First of all, put back the dollar sign where it was. It's not used as such. It's an indicator that the string appears at the end of the text.
The values of a Color object in Acrobat JS are from 0 to 1, not from 0 to 255, as you might be used to.
So divide your current values by 255 to get the correct results.
Copy link to clipboard
Copied
Thank you very much!
Copy link to clipboard
Copied
Hello I am struggling to do the code for adobe.
The drop down box is mag 58
the two answers are either:
Not Complete (Which I want red) &
Complete (Which I want green)
can someone please help me

