Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Answer: How do you limit textarea of a form

by newrisedesigns (Curate)
on Dec 19, 2002 at 14:59 UTC ( #221124=categorized answer: print w/replies, xml ) Need Help??

Q&A > input and output > How do you limit textarea of a form - Answer 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

Log In?

What's my password?
Create A New User
[james28909]: i figured it out
[james28909]: upon trying various solutions, i was forgetting to package up the script into an executable
[marto]: that'll do it
[james28909]: im glad im not in charge of anything important, like filling up peanut butter jars
marto grins

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2017-07-28 14:19 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (431 votes). Check out past polls.