Two Laptop Bag*
The moose likes Struts and the fly likes Limit the length of textarea in struts. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Limit the length of textarea in struts." Watch "Limit the length of textarea in struts." New topic

Limit the length of textarea in struts.

Varsha Patil

Joined: Jun 16, 2006
Posts: 19
Does anyone know how to set the maxlength for a textarea. I have a requirement where in the User should not be allowed to enter more than 1000 characters in a textarea.

I tried setting maxlength=1000, but then its not working.

Thanks in advance
dongfang wang

Joined: Jun 21, 2006
Posts: 1
It seems not able to set this property,

also in HTML tag "textarea"
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I don't believe you can set a maximum length on a text area. One possible work-around would be to use JavaScript to check the size of the data in the text area when the fom is submitted and then issue an error message if it exceeds 1000.

Consultant, Sima Solutions
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60741

"Varsha G A",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

JavaRanch Sheriff

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Varsha Patil

Joined: Jun 16, 2006
Posts: 19
I have changed the display name as per the naming policy.

I agree. Here's the link:
subject: Limit the length of textarea in struts.
Similar Threads
Maxlength for textarea not being set properly
javascript:Restricting the user to paste in textbox
text area character limit code without trimming
Javascript doesn't work in Mozilla
jsp-tag inside html not working???