Copy link to clipboard
Copied
I need to change the border color of a text field from black to red based on information from two other text fields. Let's say I have X and Y. X is the field on which we want to change the border color based on the Y value. But this Javascript needs to be added to the Custom Calculation Script of Y.
If X is greater than 1 and Y is greater than X, then change the border color of X to red else black.
How can I do this?
Enter the following custom calculation script in Y:
if(this.getField("X").value>1 && event.value>this.getField("X").value)
{
this.getField("X").borderColor=color.red
}
else
{
this.getField("X").borderColor=color.black
}
Copy link to clipboard
Copied
Enter the following custom calculation script in Y:
if(this.getField("X").value>1 && event.value>this.getField("X").value)
{
this.getField("X").borderColor=color.red
}
else
{
this.getField("X").borderColor=color.black
}
Copy link to clipboard
Copied
The borderColor property is deprecated. You should use strokeColor, instead.
Copy link to clipboard
Copied
This works, thank you. But I am having a weird problem. I am using this on two Y fields, and it only seems to work for one when I have the code installed on both. The person filling out the form will only use one of the Y fields. They have to choose depending on their situation. Is there any reason why it only works for one Y field if both have the same code?