5 Replies Latest reply on Aug 30, 2013 4:34 PM by CekariYH

    Force a specifik numbers of entries in a field?

    CekariYH

      Title

      Force a specifik numbers of entries in a field?

      Post

           Hi all,

            

           I'm new to Filemaker Pro and need some help.

           I have a textfield assigned as a numeric field and it's easy to set Max numbers of digits but how do you set Min number of digits?

           Ex. a field must have 4 digits like 0286 or 3251.

           How do you force it to Min 4 digits? 

            

           Regards

           Cekari

            

            

        • 1. Re: Force a specifik numbers of entries in a field?
          raybaudi

               With a validation by calculation:

               IsEmpty ( Self ) or Length ( Self ) ≥ 4

          • 2. Re: Force a specifik numbers of entries in a field?
            philmodjunk

                 What do you want to have happen if the user enters less than 4 digits?

                 A validation error can be displayed or an auto-enter calculation can provide leading zeroes to make it 4 digits. And another choice is to use the OnObjectValdation script trigger to check for valid entry, that method allows you to display dialogs and process user responses in ways you specifically design for handling the error.

                 A validation calculation limiting input to exactly 4 digits, no more, no less:

                 Length ( Self ) = 4

                 An auto-enter calculation that fills in leading zeroes to produce a 4 digit number:

                 Right ( "0000" & Self ; 4 )

            • 3. Re: Force a specifik numbers of entries in a field?
              CekariYH

                   Thanks both of you.

                   I had alredy tried the Length ( Self ) = 4 but didn't think it vorked at first, but then I noticed it only triggers when you "leave" the post and not when you "leave" the field, which I prefer.

              Any chance to make it hapend when you leave the field? 

                    

              • 4. Re: Force a specifik numbers of entries in a field?
                philmodjunk

                     A validation error can be displayed or an auto-enter calculation can provide leading zeroes to make it 4 digits. And another choice is to use the OnObjectValdation script trigger to check for valid entry, that method allows you to display dialogs and process user responses in ways you specifically design for handling the error.

                     This trigger is tripped when you exit the field so you can use the script to check the length of the characters in the field and pop up a message informing the user of the error. If you want to return them right back to the field and not let them leave until they enter a valid entry, you might use code such as this:

                     If [ Not IsEmpty ( YourTable::Field ) and Length ( YourTable::FIeld ) ≠ 4 ]
                        Show Custom DIalog [ "Data must be exactly 4 characters in length" ]
                        Exit Script [False]
                     End If

                • 5. Re: Force a specifik numbers of entries in a field?
                  CekariYH

                       Thanks PhilModJunk,

                        

                       that worked great smiley