3 Replies Latest reply on Jun 15, 2011 1:38 PM by RenéG

    Required amount of digits in a field

    RenéG Level 3

      I have a Form, done with Acrobat Pro 8 and there is one field that people need to enter their 9 digits account number.

       

      We want to set-up the pdf so that if they enter, let's say, 8 digits, they'll get a message that 9 digits is required.

       

      How do I do that?

       

      Be kind of specific as I'm not very advanced in that scripting thing. I know a bit but not much.

       

      Thanks!

        • 1. Re: Required amount of digits in a field
          George_Johnson MVP & Adobe Community Professional

          You can use a custom Validate script for this. This script would check to see if it's not blank, and if so, if there are nine characters. SOmething like:

           

          // Custom Validate script for text field
          (function () {
          
              // Get the field value
              var val = event.value;
          
              // Do nothing if the field is blank
              if (!val) return;
          
              // Make sure there are 9 characters
              if (val.length !== 9) {
          
                  // Alert the user
                  app.alert("Your message goes here.", 3);
          
                  // Optionally, reject the value
                  event.rc = false;
              }
          
          })();
          
          1 person found this helpful
          • 2. Re: Required amount of digits in a field
            RenéG Level 3

            Thanks George.

             

            Only one thing is that it deletes the numbers the customer already keyed in, if he enters let's say 8 digits.

             

            Is it possible that it leaves his entry as is? Or would that be too complicated of script?

            • 3. Re: Required amount of digits in a field
              RenéG Level 3

              Oops, never mind, I deleted that optional line you put in there.

               

              Answer this post and I'll give you full credit for the right answer.