Custom Validation Script
I am running a validation script on a calculated form field (called "% Trans"), and its behaving unexpectedly. If I get a value that is 80%, it does turn green. But then if I re-enter the numerator and denominator and get 70%, it will stay green until I put in another value that changes it. I can go back to 80% but then its red to reflect the previous 70% value...
First, I am calculating the value of this field using the Javascript:
var numerator = this.getField("Power Output in Watts").value;
var denominator = this.getField("LH Power Output").value;
if (denominator == 0 || denominator == null) {event.value = "";}
else {event.value = (numerator / denominator).toFixed(4);;}
Second, I want change the fill color of the field depending on that calculated value, so I have this JavaScript in the custom validation:
var v = this.getField("% Trans").value;
if (v>.7649) {event.target.fillColor = color.green;}
if (v<.7650) {event.target.fillColor = color.red;}
I imagine its something to do with the validation script declaring the variable v and using the getField to assign its value... I think I should be able to cut out the whole variable declaration and just have some simple if statement so as soon as the box is over .7649 it turns green, but I am not familiar at all with the syntax and how I could express it.
Please help!
