4 Replies Latest reply on Jan 7, 2013 4:06 PM by jennie ehs

    Numeric Fields - Exact digits

    jennie ehs

      Hello, I was wondering if anyone knows how to require a numeric field to be 9 digits, and only 9 digits without any commas or leading zeros. I tried using num{999999999} in the display field but that gives me leading zeros. I want to make the user input only 9 digits or else they cannot submit the form, or an error message pops up, or they cannot go to the next field or something. Any help would be greatly appreciated, I'm new to these programs!

        • 1. Re: Numeric Fields - Exact digits
          Srini Dhulipalla Level 5

          You can use the following display pattern to remove the leading zeros.

                    num{zzzzzzzzz}

           

          Place the following code in the change event of the NumericField to restrict the input upto 9 digits with JavaScript as language.    

                    if(xfa.event.newText.length >9)xfa.event.change = "";

           

          Place the following code in the Exit event of the field to check the length with JavaScript as language.

                    var intValue = this.rawValue.toString();

                    if(intValue.length<9){
                         xfa.host.messageBox("You need to enter 9 digits");
                         xfa.host.setFocus(this.somExpression);
                    }

           

          Thanks

          Srini

          • 2. Re: Numeric Fields - Exact digits
            jennie ehs Level 1

            FANTASTIC! Thank you so much, you are amazing.

            • 3. Re: Numeric Fields - Exact digits
              jennie ehs Level 1

              Srini! I need your help again. How can I do the above, but now WITH the capacity for leading zeroes?

              • 4. Re: Numeric Fields - Exact digits
                jennie ehs Level 1

                Correction, here are the things I need out of this numeric field:

                 

                -only 9 digits, error message if they do not iput total 9 digits and it not allowing more than 9

                -allowing leading zeroes, but not autofilling the leading zeroes if they don't input enough. i used your above code, and put num{999999999} in the display pattern but that autofilled zeroes

                -no commas in between numbers

                 

                THANK YOU!