2 Replies Latest reply on May 10, 2012 9:00 AM by martinangell

    Changing the colour of a field


      On a form I'm making it's important that if the value of say 'field1' is less than the value of 'field2' that the appearance of 'field1' in some way changes. That being the colour of the font or maybe the background colour of the field (this is to alert the person processing the form).


      If anyone could point me in the right direction it would be very much appreciated. I've been struggeling with this for quite awhile now.



        • 1. Re: Changing the colour of a field
          George_Johnson MVP & Adobe Community Professional

          You will have to use JavaScript, something like the following as the custom Calculate script for field 1:


          // Get the value of the other field, as a string

          var s2 = getField("t2").valueAsString;


          // Get the value of this field, as a string

          var s1 = event.value;


          // If both fields are not blank and value of s1 is less than s2,

          // set background color to red, otherwise white

          event.target.fillColor = (s1 && s2) && (+s1 < +s2) ? color.red : color.white;



          Replace "t2" with the actual name of field2. You can also adjust the colors to suit your needs. To change the text color instead, use the textColor property, or the strokeColor property to alter the border color.

          • 2. Re: Changing the colour of a field
            martinangell Level 1

            Hello George
            It works perfectly. Thank you very much for your help.