Validate Leading Zeros in Multi-Line String

Forums Classic DFFS Validate Leading Zeros in Multi-Line String

Viewing 2 reply threads
  • Author
    • #36304
      Rick Cedergren

      I have a multi-line text field where users will enter any number of 5 digit client codes separated by “,”. I would like to validate the user includes any leading zeros in the list (“00003, 00023, 00007” vs. “3, 23, 7”). Any thoughts on how this might be done?


    • #36306
      Alexander Bautz

      You can add a function like this to your Custom JS:

      function customNumberPadding(fin){
          jQuery("#dffs_"+fin+" :input").on("blur", function(){        
              var val = getFieldValue(fin);
              var arr = val.split(",");
              var newValArr = => {
                  return v.trim().padStart(5, "0");
              setFieldValue(fin, newValArr.join(","));

      Change “Name_of_your_field” to match the internal name of your field.

      Please note that this code expects the textarea to only contain numbers and no additional text.


    • #36309
      Rick Cedergren

      Thank you!

Viewing 2 reply threads
  • You must be logged in to reply to this topic.