1
0
-1

Is it possible to calculate and show the number of characters remaining as characters are being entered (a la Twitter 140 character limit)

EG: Show the number "140" as rich text, adjacent to a multi-line text field, and after the first character is typed, show "139" etc..

    CommentAdd your comment...

    2 answers

    1.  
      3
      2
      1

      Hi Sacha

      I have a sample I can share with you: It shows two options. See the attached Maestro form.


      Garymaestro-form-countFieldLength-v1-2017-10-10.zip

      1. Sacha Trube

        Not only have you answered the question, but you have also built my demo. Thanks!

      CommentAdd your comment...
    2.  
      3
      2
      1

      I've done it with this code in a form load rule in sample form:

      $(document).on('keyup', '#textField', function (event) {
        var maxLength = $(event.target)[0].maxLength;
        var fldLength = $(event.target)[0].value.length;
        $('.id-chars').text((maxLength-fldLength) + ' characters remaining');
      });

      1. Sacha Trube

        Thanks Bill,

        This is the same snippit of code provided in Gary's example.

        $(document).on('keyup', '#desc1', function (event) {
            var maxLength = $(event.target)[0].maxLength;
             var tempStr = $(event.target)[0].value;
              var fldLength = tempStr.split(" ").join("").length;
            //var fldLength = $(event.target)[0].value.length;
        
            $('.id-countDisplay1').text((maxLength-fldLength) + ' characters remaining');
          });



      CommentAdd your comment...