3 Replies Latest reply on Aug 16, 2007 9:57 PM by Rothrock

    maxChars

    jonnybennett Level 1
      I have a text box. I want to set it so that people cant type more room than there is in the textField. Is there a way to do this.
      maxChars does not really work, for example
      if I type.
      'mmmmmmmmmm'

      opposed to

      '123456789112345'

      I can fit alot less Chars in the same space, as the letter m has a lot of width. Is there a way to set a maxWidth that the text can be typed for.

      thanks to any responders, I hope you understand. J
        • 1. Re: maxChars
          Rothrock Level 5
          Well, no. Since as you have pointed out anything based on characters won't work. It is possible I suppose to use a monospaced font then it will always take up the same space.

          the width of a text field is the maxWidth that can show. There might be someway to check the length of the typed text and when it gets close to the end stop accepting any new characters. However it wouldn't be totally accurate since you could get less than "m" close to the end, but there would still be room for an "l".

          So I guess the real question is, What are you actually trying to do?
          • 2. Re: maxChars
            jonnybennett Level 1
            thanks Rothrock.
            I am simply having an input text box, that is later dsiplayed in a dynamic text box.
            However I find that users keep on adding too many chars. However like i mentioned the number of chars they can enter totally varies dependant on wjht they are typing. I guess I will just take an average of how many chars can be accepted and set that as the max chars. I assume this is what most sites would do. Thanks J.


            • 3. Re: maxChars
              Rothrock Level 5
              Yeah, pretty much that is the usual solution. Plan it like they were "M" and just let the shorter ones end before the end of the text field.

              You really could get very involved with measuring the width and all, but for what it seems you are doing that seems like overkill.