3 Replies Latest reply on Jun 2, 2014 7:15 AM by gkaiseril

    Replace all numbers with 'X' except for last 4

    NHJB MHP


      I have been able to adapt a JavaScript that I found on the Forum which allows me to replace the 1st 12 digits of a number and change them to 'X', leaving the last 4 visible.  Now if only all account numbers were 16 digits long my problem would be solved but....

      The account number in question could refer to any series of numbers or possibly even alpha characters.  It could be less than or more than 16 though I think the line could be drawn at 20.  So while I can dictate what happens for an exact number I don't know how to change the JavaScript for up to and including 20 characters (either alpha or numerical)

       

      This is what I have so far for the 16 numbers:

      reAcctNum = /^(\d{12})(\d{4})$/;

      if (reAcctNum.test(event.value) && event.value != "") {

      event.value = "XXXXXXXXXXXX" + RegExp.$2;

      }

      // end custom format script for AccountNum;

       

      It works beautifully and I even half understand what it does.  Maybe I'm making this bigger than this needs to be, feel free to make other suggestions rather than attempting to code for every possible variation. I'm using Acrobate XI Pro.

       

      Any help is greatly appreciated,

      Thanks

      Meabh