473,320 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Limit entry into TextArea

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
5 2170

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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jay | last post by:
I have an HTML form with a textarea. When passing large amount of data in the textarea, the Processing asp pages catch an error message as follows: Error Type: (0x80020009) Exception occurred. ...
6
by: Jonathan | last post by:
I want to save textarea contents to a mysql database with the paragraph breaks intact without having to type paragraph or break tags in HTML. How can I do that. So far, although it occurs naturally...
4
by: wing | last post by:
Hi all, I find a JavaScript that limits the field length in a textarea, but it is not completed. The script does not handle the copy and paste case. For example, says the textarea field...
5
by: Jesper Rønn-Jensen | last post by:
I have a textarea that must be limited to 70 characters. No big deal -- at least so I thought. * Textarea must not exceed 70 characters * Exceeding content must be cut off * Must work on input by...
10
by: M K | last post by:
Is there a way to limit an asp:textarea to 100 chars on the client side? The db only accepts 100 and chops the rest off.
6
by: @sh | last post by:
Guys, Working on a function to alert the user to too many characters being entered into a text area, I've put together this function so far borrowing bits from resource websites... function...
3
by: tadisaus2 | last post by:
Hello, I created a textarea and want to limit the maxlength to be to 255 characters. Can you help me please? <textarea rows="3" cols="55" name="abc" id="input" /></textarea> Is there any way...
3
by: teser3 | last post by:
I have the below that limits the textarea input to 500 characters but cant get the alert message to work. It doesnt show anything. Please advise. <script language="javascript"...
7
by: =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?= | last post by:
I need to emulate the missing "maxlegth" attribute in "textarea" fields but all my Google searches either lead to obsolete scripts that overwrite the "value" property (thus losing caret position)...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.