473,789 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2224

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.len gth > 200) this.value =
this.value.subs tr(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.len gth > 200) this.value =
this.value.subs tr(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="ret urn (this.value.len gth <= 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
23082
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. The error is generated once the trim or length or replace function is called on the field when long text is passed in the textarea.
6
63139
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 when I save the contents to a file, it doesn't break up the paragraphs properly when I save it to my database. Thanks! Jonathan http://thewebdevelopment.com
4
29538
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 length is limited to 5 and a 6-character length text is pasted, no event is triggered. (The script only handles onKeyPress and onKeyUp)
5
12157
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 keyboard (keypress, keyup events) * Must work on pasted input from context menu * Must work on pasted input via CTRL+V and similar * Must work on pasted input via browsers menu>Edit>Paste * Must work in Mozilla + IE and coded via W3C standards
10
1641
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
3488
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 Ash_LimitMaxTextAreaCharacters(TheMaxCharacters,TheFriendlyFormName) { if(document.myform.box.value.length > TheMaxCharacters) { alert('Sorry but '+TheFriendlyFormName+' contains too many characters,
3
2247
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 to do with javascript? I will trim off when users reach the maxlength. Thanks.
3
4205
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" type="text/javascript"> function limitText(limitField, limitCount, limitNum) { if (limitField.value.length limitNum) { limitField.value = limitField.value.substring(0, limitNum); alert("You are trying to enter more than 500 characters"); } else {
7
3116
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) or to complex solutions that work on top of specific frameworks. Do you have some reference on how to do it? I'd like to make it work in at least Firefox and IE 6 and 7. Thank you in advance,
0
10195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9016
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6765
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4090
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2906
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.