4 Replies Latest reply on Sep 22, 2010 12:21 AM by sunmoonstar.13

    Countdown Field Characters

    Mitch

      Title

      Countdown Field Characters

      Post

      I have a text field that I have had to limit to a certain number of characters - 500 (due to the bug with FMP 11 - Cutting text crossing pages).  

      So I have an additional field with a calculation that counts down the remaining characters using the 'length' function.   However, the countdown field only updates when you exit the text field.  This does not help when you keep typing, only to find that you have well exceeded the allowable characters...  

      Is there any way of making the count down field update as you type?

      Perhaps even a warning when you get close to the allowable number of characters, or the ability to delete when you go over the allowable characters?

        • 1. Re: Countdown Field Characters
          sunmoonstar.13

          Try this:

          Instead of a calculation field for the countdown field, make it a plain number field, and attach a script trigger to the text field - OnObjectModify. Use a script like this:

           

          Set Field [ Your_table::Countdown ; 500 - Length ( Your_table::Text_field ) ]

          If [ Length ( Your_table::Text_field ) = 475 ] 

                Show Custom Dialog [ "Countdown" ; "You have 25 characters left." ]

          Else If [ Length ( Your_table::Text_field ) > 500  ]   

                Set Field [ Your_table::Countdown ; "0" ]

                Show Custom Dialog [ "Countdown" ; "No more characters left." ]
                
                Set Field [ Your_table::Text_field ; Left ( Your_table::Text_field ; Length ( Your_table::Text_field ) - 1 ) ]

          End If

           

          This will show a warning dialog box when the text reaches 475 characters. When it hits 501 characters another dialog pops up and the last character is deleted, limiting the field to 500 characters.

           

          Nick

           

          • 2. Re: Countdown Field Characters
            Mitch

            Thanks Nick,  it works well..

            • 3. Re: Countdown Field Characters
              Mitch

              Nick,

              Can this be script be adapted to count lines of text instead of characters.  As Carriage Returns (Enter) counts as one character.

              Mitch

              • 4. Re: Countdown Field Characters
                sunmoonstar.13

                As far as I know, FMP doesn't have any function for counting lines in a text field. I think your best bet is to play around with the character count and maybe adjust the size of the text field on the layout to get the results you want.

                Nick