3 Replies Latest reply on Jan 30, 2007 11:50 AM by jonnybennett

    limit number of lines

    jonnybennett Level 1
      I know how to limit the number of characters that a user can input, but is there a way to limit the number of lines that a user can input into a textbox.
        • 1. Re: limit number of lines
          KnowRama
          Here is a workaround..
          The code below restricts the entry of lines based on the text height.. So you would have to predetermine the text Height based on the number of lines that you prefer to restrict.

          --KM

          • 2. Re: limit number of lines
            kglad Adobe Community Professional & MVP
            if your textfield is multiline (and i assume it is), it makes no sense to restrict to a certain number of lines unless you want to prevent it from needing to scroll. otherwise, make your textfield smaller.

            to prevent it from needing to scroll you can use:

            • 3. Re: limit number of lines
              jonnybennett Level 1
              Firstly thanks kglad and KnowMind for your responses.

              Why I wanted this. I have a textfield that a user fills in. This text is then displayed in another textfield that can't be scrolled at a later point. Therefore I need to limit the number of lines that they use when filling in the first textfield so that it will be fully displayed in the later textfield.

              knowmind, your code works, but doesn't do what I wanted. as it increases the size of the textfield being filled out, rather than limitting it.

              kglad (as usual) you have done what I wanted, however if a user tries to edit his work, eg, goes back to the top line and clicks enter any line that goes over the height is lost and can't be retrieved, which would be annoying. Therefore instead I am going to use the following code:

              commentTxt.maxChars=420;
              remForcedLines = commentTxt.text.split("\r").join(" ");

              It simply removes any forced lines that are in textfield 1. Therefore as long as maxChars is under the maxchars in textfield 2, it will display fully. Obviously this wouldn't be particularly practicle for large textfields but as you can see it is only 420 chars long.

              So thanks to both of you for your help. J.