1 Reply Latest reply on Mar 8, 2017 1:09 AM by try67

    Script to change text field's fill color depending on text entered

    RedbackVisuals

      Hi All,

       

      I am working on a creating a PDF form with text fields that need to change the fill color depending on values entered (value 1 turns fill color red, value 2 turns fill color green, value 3 turns fill color blue, etc.). I was wondering if it is possible to write a JavaScript which will set the text field's background color to the color required based on the numeric value entered. Any ideas?

       

      Thank you,

      Donna    

        • 1. Re: Script to change text field's fill color depending on text entered
          try67 MVP & Adobe Community Professional

          Yes, it is. You can use this code as the field's custom validation script:

           

          if (event.value=="1") event.target.fillColor = color.red;
          else if (event.value=="2") event.target.fillColor = color.green;
          else if (event.value=="3") event.target.fillColor = color.blue;
          else if (event.value=="4") event.target.fillColor = ["RGB", 1, 1, 0]; // this is how you define a custom color, yellow in this case
          else event.target.fillColor = color.white;