By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,441 Members | 996 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,441 IT Pros & Developers. It's quick & easy.

Limit entry into TextArea

P: n/a
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

Jan 31 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a

JohnSouth wrote:
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.

Jan 31 '06 #2

P: n/a
impaler wrote:
JohnSouth wrote:
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.


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
Jan 31 '06 #3

P: n/a
Why not limit length of input in the first place?


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

Feb 1 '06 #4

P: n/a
impaler wrote:
Why not limit length of input in the first place?


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
Feb 1 '06 #5

P: n/a
Thanks to All. It's clear to me now, and it makes a big improvement to
the entry screen.
Cheers

John South
www.wherecanwego.com

Thomas 'PointedEars' Lahn wrote:
impaler wrote:
Why not limit length of input in the first place?


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


Feb 4 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.