11 Replies Latest reply on Sep 20, 2013 6:56 AM by Pandora273

    Formatting A Percentage Field

    ELucca

      I am trying to format a text field to produce a percentage. Currently when I input 50 into the field, it produces 50.00% (rather than 50%).  I am using a javascript that another member recommended, but I would like to know how I can remove the 2 decimal places. 

       

      I am currently using the following document-level JavaScript:

       

      function percentKeystroke() {

          AFNumber_Keystroke(2, 0, 0, 0, "", false);
      }

      function percentFormat() {

          event.value = util.printf("%.2f%", event.value);
      }

       

      Along with the following for the custom format and keystroke scripts for the field:

       

      // Custom Format script
      percentFormat();

       

      // Custom Keystroke script
      percentKeystroke();

       

      Thanks in advance for your help!