1 Reply Latest reply on Jun 29, 2017 1:57 PM by gkaiseril

    How do you get the zero to stay in a field after you click out of it.

    ICastro2010 Level 1

      If my user enters a number that starts with zero, the zero disappears once they click out of the field.  I need for the zero  to stay.  For example, they enter 09876, only 9876 shows

      This is the script that I have so far in it.

       

      .

      var desiredLength = 9; // the number of digits the user should enter

      event.rc = true;
      if (event.value && event.value.length!=desiredLength) {
          app.alert("You must enter exactly " + desiredLength + " digits.");
          event.rc = false;
      }

        • 1. Re: How do you get the zero to stay in a field after you click out of it.
          gkaiseril MVP & Adobe Community Professional

          The over whelming number of programs and applications do not show leading zeros. Leading zeros are generally associated with character strings and need special formatting.

           

          Working within a field, the event.value will retain the leading zeros. To read the value of a different field you need to use the valueAsString method. One can force the value to have leading zeros by using the util.printf method. You should be aware that the format for a field only affects the displayed value and not the actual value of the field.