2 Replies Latest reply on Mar 24, 2014 1:35 PM by TSGal

    Automatically adding spaces/tabs to a field while the user is typing

    MelissaBurgess

      Title

      Automatically adding spaces/tabs to a field while the user is typing

      Post

           I am wondering what the script/formula would be if i want to format a field to add spaces as the user is typing a 10 digit line. For exampa: they would type 1234567891 but it would format like 123  45 67  891.

        • 1. Re: Automatically adding spaces/tabs to a field while the user is typing
          SteveMartino

               Here's a basic one using a modified Phone Filter:

                

               Left(Contacts::Home Phone;3) & " " &

               Middle(Contacts::Home Phone;4;2) & " " &

               Middle(Contacts::Home Phone;6;2) &" " &

               Middle(Contacts::Home Phone;8;3)

                

               But it needs to be modified to prevent users from entering non numbers, or entering more then 10 numbers

          • 2. Re: Automatically adding spaces/tabs to a field while the user is typing
            TSGal

                 Melissa Burgess:

                 Thank you for your post.

                 Set up an Auto-Enter Calculation for the field.  If you are sure there will only be digits and 10 characters, assuming the field is named Code, a possible formula would be:

                 Let ( C = Filter ( Code ; "0123456789" ) ; If ( Length ( C ) = 10 ; Left ( C ; 3 ) & " " & Middle ( C : 4 ; 2 ) & " " & Middle ( C ; 6 ; 2 ) & " " & Right ( C ; 3 ) ; Code ) )

                 Be sure to uncheck the option "Do no replace existing value of field (if any)".

                 In essence, I filter out any characters that are not digits, and then check to make sure the length is 10.  If so, then I place one space between the third and fourth characters, the five and sixth characters, and the seventh and eighth characters.  Otherwise, I leave the entry alone.

                 Let me know if you need additional clarification.

                 TSGal
                 FileMaker, Inc.