Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Changing border color of a separate text field

New Here ,
Jul 13, 2024 Jul 13, 2024

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?

TOPICS
PDF forms
839
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Jul 13, 2024 Jul 13, 2024

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
}

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 13, 2024 Jul 13, 2024

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
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 14, 2024 Jul 14, 2024

The borderColor property is deprecated. You should use strokeColor, instead.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 16, 2024 Jul 16, 2024
LATEST

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines