6 Replies Latest reply on Oct 27, 2014 9:23 AM by jjfcpa

    Input masks and text limit

    jjfcpa

      Been working with FM for a short while and it seems that one of the limitations that I've encountered compared to some other developmental systems is input masks and controlling the text entry.

       

      Also a little unsure about auto-enter calculations. It looks to me like they fire AFTER data has been entered rather than as data is entered, so you can't really use them to control input other than formatting the data entered after it is completed.

       

      The alternative method of controlling input is the use of a script trigger (onobjectchange or onobjectkeystroke). Since this is a script trigger then you'll have to use a script to control the input which seems to be more complicated than it needs to be; especially if you need to not only limit the text entered (number of characters), but also add formatting to the data such as parenthese and hyphen when entering a phone number.

       

      Just wondering if I am approaching this wrong and if there is a preferred or better way to approach this.

        • 1. Re: Input masks and text limit
          keywords

          It is not clear (at least to me) exactly what you are getting at here, but let me guess:  based on "especially if you need to not only limit the text entered (number of characters), but also add formatting to the data such as parenthese and hyphen when entering a phone number" I am guessing that your immediate need is to standardise the formatting of phone numbers. Am I warm? IF SO …

           

          You can certainly accomplish this using and autoenter calculation. As you have discovered, the calc fires after the data has been entered, but this makes sense if you think about it. And you CAN use them to control input in other ways than just formatting. The trick is to learn to use the Let ( ) function. I have used this with a phone number field to:

           

          1.     detect whether the user has entered a mobile or landline number or some other and then determine whether there are too many or too few digits

          2.     detect whether any alpha characters have been entered

          3.     post back into the field the data the user has entered with an appropriate message if either of the above rules have been breeched

          4.     if data entered is correct according to the rules I have established in the calc, reformat the phone number according to the rules appropriate to the number entered

           

          Let ( ) is a very powerful tool.

          • 2. Re: Input masks and text limit
            ChadAdams

            jjfcpa wrote:

             

            Been working with FM for a short while and it seems that one of the limitations that I've encountered compared to some other developmental systems is input masks and controlling the text entry.

             

            Also a little unsure about auto-enter calculations.  It looks to me like they fire AFTER data has been entered rather than as data is entered, so you can't really use them to control input other than formatting the data entered after it is completed.

             

            The alternative method of controlling input is the use of a script trigger (onobjectchange or onobjectkeystroke).  Since this is a script trigger then you'll have to use a script to control the input which seems to be more complicated than it needs to be; especially if you need to not only limit the text entered (number of characters), but also add formatting to the data such as parenthese and hyphen when entering a phone number.

             

            Just wondering if I am approaching this wrong and if there is a preferred or better way to approach this.

             

            Hello,

             

            FileMaker does things a little different than some other languages.  For those of us who grew up on FileMaker this seems normal, but I understand how frustrating it can be.

             

            Check out Field Validation (next tab over from the auto-enter tab on field options) to limit things like:

            1. Data Type
            2. Max Characters
            3. Not Empty
            4. Unique
            5. In a Range
            6. or validate by calculation

             

            Use an auto enter calculation for reformatting data on the fly (adding parantheses or hyphens to phone numbers).

             

            Hope that helps.

             

            Chad

            • 3. Re: Input masks and text limit
              jjfcpa

              Thank you for the reply.  This far, I think the best option I've found is the onobjectchange script trigger, but I do admit, I haven't used the LET function at all and perhaps that's what I need to investigate a little more.

              • 4. Re: Input masks and text limit
                erolst

                jjfcpa wrote:

                 

                Thank you for the reply.  This far, I think the best option I've found is the onobjectchange script trigger, but I do admit, I haven't used the LET function at all and perhaps that's what I need to investigate a little more.

                 

                The best options in your case are field validation to ensure the integrity of the data and the record, and an auto-enter calculation to format the data as desired. Keep in mind that triggers are applied to objects on layouts, not fields in the schema.

                 

                Also, Let() is an invaluable tool when it comes to writing better calculations – but it's just a helper function; you still have to know what your calculations are supposed to do, and what “real” functions are appropriate for the task at hand.

                • 5. Re: Input masks and text limit
                  erolst

                  keywords wrote:

                  The trick is to learn to use the Let ( ) function.

                   

                  I think the “trick” (if you can call it that) is to know “the other” functions – and, of course, to have a plan; then you can use Let() to write more effective, better readable & more easily debuggable calculations …

                  • 6. Re: Input masks and text limit
                    jjfcpa

                    I've written a couple of scripts to trap for the length of the data and to enforce "numbers only with a text limit" and they seem to be working well.

                     

                    I'm coming from languages that permitted enforcement of the data entry at the time that data was entered rather than when you attempt to save it.  Actually, we did both just to be safe. 

                     

                    It would certainly be easier to use the auto-calc and validation in the database, but I think I prefer telling the user immediately that they've entered too many characters rather than wait till they've entered 15 extra characters. 

                     

                    I'll probably resort to the auto-enter calcs to format the phone number correctly use my onobjectmodify to enforce that they can enter numbers only.