4 Replies Latest reply on Oct 22, 2014 12:55 PM by mach1rcode

    Script putting fractions instead of ABCDEF

    mach1rcode

      Running Acrobat Standard X.

      I have a little bit of Javascript which is pulling the initials from a full name in one form field and placing the persons initials into a textbox throughout my document.

      My script works very well, except if there is a capital A,B,C,D,E, or F. In those instances it puts 1/2 for A, 1/4 for B, 3/4 for C, 1 for D, 2 for E, and 3 for F.

      Jane Doe would become J.1. (The 1,2,and 3 are shown as exponents). If I replace event.value in my script with an app.alert everything shows correctly in the message box.

       

      Can someone please help, starting to pull my hair out. Below is the script. NameC2 is my Full Name field. Thanks

       

      function Intials(cString) {

      return cString.replace(/\W*(\w)\w*/g, '$1.').toUpperCase()

      } // end Initials function;

       

      var cName = "NameC2";

      event.value = "";

      var oName = this.getField(cName);

      if(oName ==  null) {

      app.alert("Error accessing field \"" + cName + "\"", 0, 0);

      } else {

      event.value = Intials(oName.value); // set field value;

      }