In the second line use
f.textColor = ...
Your suggestion work but if value is negative color should be red right?
EDIT:sometimes if negative color is black if positive red, other times whatever value it's always red.
it's all mixed up, I just don't get it.
Yes, it's a mistake in the documentation.
Where did you place the code, exactly? Under what event?
I tried in both validate and calculation. When I input code and enter positive value color is black,when input negative color is red but when then go to positive again it stays red.
Keep in mind it will only update after you leave the field, as that's when the value is "applied".