Limit entry into TextArea

I

impaler

JohnSouth said:
Hi

In a TextBox I can set a maximum size for the entry.
Is there a way of limiting the number of characters being entered into
a TextArea control?

John South
www.wherecanwego.com

<textarea onkeypress="if (this.value.length > 200) this.value =
this.value.substr(0, 200);">
</textarea>

do this on onblur too, to avoid copy paste and if there are other
scenarios to put more too.
 
T

Thomas 'PointedEars' Lahn

impaler said:
<textarea onkeypress="if (this.value.length > 200) this.value =
this.value.substr(0, 200);">
</textarea>

do this on onblur too, to avoid copy paste and if there are other
scenarios to put more too.

Why not limit length of input in the first place?

<textarea onkeypress="return (this.value.length <= 200);"></textarea>

where the parens are not necessary. This should be extended to tell
the user why the number of characters is limited.


PointedEars
 
T

Thomas 'PointedEars' Lahn

impaler said:
It's a javascript topic so I thought he wants a javascript solution :)

You are talking nonsense. Mine *is* a JavaScript solution as well, which,
in contrast to yours, limits the length of input on the first place rather
than correcting the value afterwards. And any solution for this problem
cannot qualify as a JavaScript solution alone, because the DOM is involved
always.

Learn to quote.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top