View Full Version : Resolved Help With Textarea Tag

Joseph Witchard
11-04-2008, 05:12 AM
How do you set the textarea tag to where when the sentence becomes too long for the textarea, it automatically starts typing on a new line? (Like the textarea I'm typing in to make this post.)

11-04-2008, 05:15 AM
you can use html attributes: wrap="soft" wrap="hard" wrap="off"

hard: wraps text and includes the carriage returns in the textarea value
soft: wraps text but doesn't add carriage returns
off: obviously, no word wrapping

you'll probably want to use soft

it's odd though, iirc most browsers default to textarea word wrapping

Joseph Witchard
11-04-2008, 05:34 AM
Is there anything else that can be done? Even using the wrap attribute, it still doesn't work in either Firefox or Opera. Only Internet Explorer:( I even looked up the attribute values for IE browsers and tried them instead. Nothing.

11-04-2008, 05:39 AM
opera seems to disable much code like that it even disables the body code i use to disable rightclicking and drag and drop.

i have been using
wrap="PHYSICAL" does that even work?

Joseph Witchard
11-04-2008, 05:58 AM
Got it working. Thanks:) Just out of curiosity (I think I know what the answer will be), there doesn't happen to be any W3C standard way of doing this, is there?

11-04-2008, 06:44 AM
You could use javascript to set the wrapping but then again this is just going around the main issue.

window.onload = function()

11-04-2008, 06:28 PM
Joseph: what was your solution? (And I apologize for not checking in all browsers before posting.)

Joseph Witchard
11-05-2008, 12:09 AM
Dang, I was hoping no one would ask:p It was just a stupid error on my part. When I was testing the textarea by typing in it, I just held down a key and watched whatever character I selected type as long as it could across the textarea. Then, when I was posting here, I did the same thing (I don't remember why I did so), but I saw that it did the same thing here, too. I didn't know that you had to actually be typing out words and such to get the text to wrap in the textarea. Sorry for any inconvenience I caused you guys:o

Major Payne
11-05-2008, 04:19 AM
Might even play with another example :p:
<textarea name="Limiting Textarea Text" rows="2" cols="20" onkeyup="textLimit(this, 40);"></textarea>

Between head tags:
<script type="text/javascript">
function textLimit(field, maxlen) {
if (field.value.length > maxlen + 1)
alert('Your input has been truncated!');
if (field.value.length > maxlen)
field.value = field.value.substring(0, maxlen);

Joseph Witchard
11-05-2008, 08:42 AM
All right, cool:)