1 Reply Latest reply on Aug 18, 2014 3:37 PM by gkaiseril

    Custom format multiple fields

    xavierharrell

      I'm looking to format multiple total fields to two decimal spots. Is there a way to do this without having to put each custom format script on each field?

        • 1. Re: Custom format multiple fields
          gkaiseril MVP & Adobe Community Professional

          I would create a script to do the work:

           

          // array of field names to process

          var aFieldNames = new Array("Text1", "Text2", "Text3");

          // loop through the field names;

          for(var i = 0; i < aFieldNames.length; i++) {

          var f = this.getField(aFieldNames[i]); // get the field;

          f.setAction("Format", 'AFNumber_Format(2,0,0,0,"",true)'); // set the format;

          } // end for field names loop;

           

          Adobe has provided some documentation about the AFNumber_Format function.

           

          You could also set the keystroke and validation routines for numbers at the same time.