Steven wrote:
i need to force a carriage return with a textarea field at X number of
characters. anybody know how to do this?
You can't reliably do this, though you may be able to get it to work in
a particular browser, but certainly not all.
One of the biggest problems is that you have no idea where the
insertion point is. You can't simply add a return after 5 keystrokes,
or to the end of the string if it's more than 5 characters long.
Say you add an onkeydown event the checks the number of characters, and
when the user types a 5th character, you add a return to the end of the
string to add a 6th character.
But the cursor is still at the 5th, before your return, so any further
input will go before your return - you can't move the insertion point
programmatically.
Another is if the user puts the insertion point somewhere else in the
string and starts typing - say changing the first 5 character phrase.
you now must get rid of all your returns and put them back in the right
place - each time a key is pressed.
There are many more scenarios where this will fail, as no doubt you
have discovered.
Rob.