Is there an HTML5 attribute to set the maximum amount of characters in a textarea or other form?
I want a yes/no answer not some other method using javascript.
Asked
Active
Viewed 1.3k times
1

Web_Designer
- 72,308
- 93
- 206
- 262
2 Answers
2
Yup, maxlength works still: http://jsfiddle.net/xhqsB/1/ (demo has textarea and input type of text)
Beware that it is fairly easy for the client to bypass these restrictions, so if you are submitting data to a form, have the server-side script check the length of the submitted data.

penguinrob
- 1,431
- 3
- 17
- 39
-
Do you know what browsers support that attribute? – Web_Designer Apr 11 '11 at 18:47
-
I've tested in Firefox 4, Chrome, and Safari, and it works in all three – penguinrob Apr 11 '11 at 18:53
-
2K, I just tested it in IE8, and it's not supported for the textarea only the input field is supported. – Web_Designer Apr 11 '11 at 19:03
-
Good to know, I'm on a mac and don't have IE. Do you have access to IE9? – penguinrob Apr 11 '11 at 19:04
-
The best browser in my opinion is Google Chrome. It is fast and supports almost everything. I have looked at IE9 but have not downloaded it. The only reason I have IE8 is because I am a web-developer, and I use it for browser testing and more people use IE8 than IE9. – Web_Designer Apr 11 '11 at 19:13
-
Also, I tested it in Firefox 3.6 It doesn't support the maxlength for textarea. – Web_Designer Apr 11 '11 at 19:20
-
2You said for HTML5 so why is IE8 important? – BritishDeveloper May 10 '12 at 10:17
0
see: textarea – text input area - HTML5
the maxlength
attribute is new to HTML5 for <textarea>
but has been available for <input type="text" />
for a while
see other similar questions:
jquery - TextArea MaxLength - Supported or Not Supported? - Stack Overflow
How to impose maxlength on textArea in HTML , Javascript - Stack Overflow