Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

How do you limit textarea of a form

by Anonymous Monk
on May 24, 2000 at 23:59 UTC ( #14653=categorized question: print w/replies, xml ) Need Help??
Contributed by Anonymous Monk on May 24, 2000 at 23:59 UTC
Q&A  > input and output


there is a textarea in a form that people seem to enjoy entering 5 spaces in between each line they type. this causes a problem when i print the info on paper that has preprinted info on it. Unlike the normal text box, MAXLENGTH is not an attribute of a textarea. Therein lies my problem

Answer: How do you limit textarea of a form
contributed by ZZamboni

Or if you want to remove blank lines:

If you want to clump everything into a single line (maybe for reformatting it yourself, see Text::Wrap or my Nicely format a list or a string snippet):
s/\s+/ /g;
If you want to cut it to the first 5 non-empty lines:
I don't think there is an HTML attribute to restrict the number of lines in a TEXTAREA.


Answer: How do you limit textarea of a form
contributed by reptile

A possible perl solution is removing some of the newlines, like:


which will replace three or more newlines in a row with two (two to preserve double-spacing of paragraphs).

Answer: How do you limit textarea of a form
contributed by newrisedesigns

In the text of the page, put "X character limit." Then $text = substr($text, 0, X)

You can also add the following as a guide to your form-submitters.

<input value="X" size="3" name="msgCL" disabled> <script language="JavaScript"> <!-- var supportsKeys = false function tick() { calcCharLeft(document.forms[0]) if (!supportsKeys) timerID = setTimeout("tick()",200) } function calcCharLeft(sig) { clipped = false maxLength = 200 //Change this. if (document.creator.signature.value.length > maxLength) { document.creator.signature.value = document.creator.signature. +value.substring(0,maxLength) charleft = 0 clipped = true } else { charleft = maxLength - document.creator.signature.value.length } document.creator.msgCL.value = charleft return clipped } tick(); //--> </script>

Hope this helps

Please (register and) log in if you wish to add an answer

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (4)
    As of 2020-09-19 12:43 GMT
    Find Nodes?
      Voting Booth?
      If at first I donít succeed, I Ö

      Results (114 votes). Check out past polls.