Web_Designer
Web_Designer

Reputation: 74540

HTML5 textarea character limit attribute

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.

Upvotes: 1

Views: 12733

Answers (2)

MikeM
MikeM

Reputation: 27405

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

Upvotes: 0

penguinrob
penguinrob

Reputation: 1459

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.

Upvotes: 2

Related Questions