textarea / text

I have a edit control that the users types in a description.  I want to limit their description to 256 characters.  I want the visible capability of a 'text area' tag that allows scrolling and multiple rows, with the 'maxlength' attribute of a 'text' tag.  To put it another way I want a 'Textarea' with a maxlength of 256 characters. Any suggestions?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I am not aware of any such attribute in the textarea tag, though you  can look into http://www.w3.org/MarkUp/ for the latest draft of HTML 4.0

try this

function checklen() {
   if (document.myform.test.value.length > 256) {
        alert('limit to 6 lines only');
        return false;
        return true;


<form name="myform">
<textarea name="test" cols="40" rows="5" wrap="physical" onblur="return checklen()"></textarea>

the text will wrap around by itself and 40*6 = 240 chars will be allowed with the javascript function


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You could also use on the onKeyPress event of the textarea, and then call a javascript function that would check the length, and not let it get any bigger.  This way, text after 256 chars wouldn't even be displayed.

:) dapperry
you could check in the recieving page the length of the string and if it exceeded
the limit then inform the user...

this could be used as a
non-javascript-enabled-browser solution...


<cfif #len(nameofstring)# GT 256>
string too big!!!
wills1300Author Commented:
This works very well.  I tried the other suggestion about using the onkeypress event.  I like how it only lets you type in 256 characters and no more, but it would not be invoke if someone pasted in a some text, and once you hit the 256 char, you can hit the 'backspace' button to erase because the JS message would appear.

Thanks everyone.
Yeah I guess you would want to use both the onKeyPress and onBlur events.  Glad it works Ok for you.

:) dapperry
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.