1 Reply Latest reply on Sep 13, 2013 1:00 AM by try67

    Change field color onBlur & onFocus with variable - Coding oversight

    LAIHDT Dan Level 1

      I've got a very simple task that's giving me a headache. I think I've been looking at it too long.

       

      Here is my code for a field in an AcroForm:

       

      onFocus -

      if (event.target.strokeColor == color.red){

      event.target.strokeColor = color.red;

      event.target.fillColor = color.white;

      }

      else{

      event.target.strokeColor = ["CMYK",0,0,0,.15 ];

      event.target.fillColor = color.white;

      }

      onBlur -

      if ((event.target.strokeColor == color.red) && (event.target.value == "")){

      event.target.strokeColor = color.red;

      event.target.fillColor = ["CMYK",0,0,0,.05 ];

      }

      else{

      event.target.strokeColor = color.white;

      event.target.fillColor = ["CMYK",0,0,0,.05 ];

      }

       

      The code works as it should except for the IF statement that it seems to ignore.

      There is another 'validation' code on a submit button which changes any unfilled & required fields to a red stroke.

       

      So what I'm after is for the fields to change to a 'nice highlight' when in normal use but when someone clicks submit and an unfilled field is set to a red stroke, when the user goes back into that field it stays red and only changes back if they have actually entered something into the field or else it will stay red.

       

      Currently the field has the 'nice highlight' onFocus and onBlur but when the stroke is changed to red, it doesn't stay red and just uses the 'nice highlight' properties (white and gray).

       

      Who can find the problem? Happy to post the submit button code if needed.