2 Replies Latest reply on Feb 12, 2013 1:32 PM by wdg1932

    Need zero filled text field to export leading zeros


      I am working on a form that needs to combine several fields one of which has leading zeros. 


      Using information mostly from this site I have put the following together.  It works exactly as I want Except the field MemberNumber field does not bring over any leading zeros.  I thought the ValueasString would do that for me but does not.



      // Custom calculation script
      (function () {

      // Get the field values, as strings
      var sdc1 = getField("ABA").valueAsString;
      var sdc2 = getField("MemberNumber").valueAsString;
      var sdc3 = getField("CheckNo1").valueAsString;

      // Set this field value by concatenating the field values
      event.value = (sdc1 + sdc2 + "C" + "  " + sdc3) ;



      The field MemberNumber uses the following (also from here I think) and works great for that field in filling in the leading zeros.


      // Custom Format script

      (function () {

          // Get the character limit for this field

          var max_chars = event.target.charLimit;

          // Define the pad character to use

          var pad_char = "0";

          // If the field is not blank and there is a character limit, pad value with leading zeroes

          if (event.value && max_chars) {

              event.value = (new Array(max_chars + 1).join(pad_char) + event.value).slice(-max_chars);




      Thanks for any help. Bill