4 Replies Latest reply on Apr 11, 2013 11:49 AM by philmodjunk

    Character limit



      Character limit


            I'm trying to implement a character limit that will not let the user conintue typing once the limit is reached.  What I have so far is the following but it's not working the way I'd like.  First off I'm unsure how to count spaces as well.  Second, I can hit the limit, the rror message pops up, the limit is in theory correct (minus the lack of space count) but if you continue typing it removes the last character typed and replces it with the latest one you've typed instead of completely ignoring the last thing typed.


           Set Variable [$Count; Value: Length ( Purchases::Comments )]

           If [$CCount  320]

           Show Custom Dialog [custome dialog here]

           Set Variable [$CommentFilter; Value:Left ( Purchases::Comments; 319)]

           Set Field [Purchases::Comments; $CommentFilter]

           End If

        • 1. Re: Character limit

               Is this performed from the OnLayoutKeystroke Trigger?

               If so try putting: ExitScript [false] just above the EndIf. This will keep the last character pressed from being entered into the field when it exceeds the character count.

               Have you tried setting the Maximum Characters validation option in Field options instead?

               I don't understand why there is an issue with spaces. The Length function counts all characters in the field--including space characters.


          • 2. Re: Character limit

                 Ok, maybe I miss counted.  If you say that length counts spaces then I'll certainly take your word for it.


                 The trigger is on the field itself on keystroke and I tried first with keystroke then went to validation but found it was only when I committed the record that validation would occur.  I'd rather have it stop the second the character limit is reached.  I will add the exit script and see what happens.



            • 3. Re: Character limit

                   Works exactly how I wanted it to, thank you Phil.


                   Can you please explain to me what exactly ExitScript [False] does and why you I have to put [False]?


                   You've made me add that to other scripts before and I've yet to arrive at a logical conclusion.

              • 4. Re: Character limit

                     Look up:

                     Setting up script triggers
                     In Filemaker Help and read the notes at the very bottom.