473,387 Members | 1,485 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,387 software developers and data experts.

textarea length setting

Hi.

Is there any way to set a textarea to a limited number of characters, like
the text element?

PS I'm not talking about line width and num lines, which I know you can set.

Thanks.
Jul 20 '05 #1
2 5597
Bill wrote:
Is there any way to set a textarea to a limited number of characters, like
the text element?
<!-- Allows no more than 10 characters -->
<textarea ... onkeyup="if (this.value.length > 10) this.value =
this.value.substring(0, 10);">...</textarea>

This works in IE 6 SP-1 and Mozilla/5.0 rv:1.5 on Win2k.
But since client-side scripting can be disabled or (partly)
not supported, server-side form checking is also required.
PS I'm not talking about line width and num lines, which I know you can set.


How do get that idea? Line width and number of lines is exactly what you
cannot restrict in contrast to the length of the value. You can merely
define how long a line *should* be *displayed* before the text is *wrapped*
and how many wrapped lines *should* be *displayed* simultaneously without
*scrolling*.
PointedEars

Jul 20 '05 #2

"Thomas 'PointedEars' Lahn" <Po*********@web.de> wrote in message
news:3F************@PointedEars.de...
Bill wrote:
Is there any way to set a textarea to a limited number of characters, like the text element?
<!-- Allows no more than 10 characters -->
<textarea ... onkeyup="if (this.value.length > 10) this.value =
this.value.substring(0, 10);">...</textarea>

This works in IE 6 SP-1 and Mozilla/5.0 rv:1.5 on Win2k.
But since client-side scripting can be disabled or (partly)
not supported, server-side form checking is also required.


Thanks.
PS I'm not talking about line width and num lines, which I know you can
set.
How do get that idea? Line width and number of lines is exactly what you
cannot restrict in contrast to the length of the value. You can merely
define how long a line *should* be *displayed* before the text is *wrapped* and how many wrapped lines *should* be *displayed* simultaneously without
*scrolling*.


Didn't know that either. Thanks again Thomas...


Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

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...
1
by: Volt | last post by:
is there any way to select and mark part of text in textarea by regular expression? i need to select the first string in textarea whitch is like xxxxx,xxx where x is any character
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...
9
by: Paul Gorodyansky | last post by:
Hi, FAQ tells how to insert (or replace0 a text at a caret position in Mozilla (and same works for Opera 8+), for example, at http://www.faqts.com/knowledge_base/view.phtml/aid/1661 it talks...
3
by: Jarek Mielcarek | last post by:
hi all, in xml file I have some fields which are source for <textarea> element. I'd like to transform this file using xslt and set the rows property of <textarea> depend of lines in some source...
3
by: arashamiri | last post by:
Hi, I wrote an auto resizing textarea: function myMax(anumber, another) { if (anumber > another) { return anumber; } return another; }
1
by: Garry Jones | last post by:
I have been using this code for sometime. I can use it to show the user how many remaining characters are reamaining in a text area. Now I need to develop the code and dont know where to start. ...
3
by: zjw2112 | last post by:
Hello. I have some javascript code that dynamically creates a textarea and sets the wrap value to hard, which I thought would preserve CR/LF in the textarea: var otherTextArea =...
6
by: gilbert.george | last post by:
Hi, I am setting the width of a textarea using the style.width to ensure the textarea is exactly the right width. I want to set the height/rows of the textarea depending on it's contents (so...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.