Is there an HTML5 attribute to set the maximum amount of characters in a textarea or other form?
I want a yes/no an开发者_运维百科swer not some other method using javascript.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.
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
精彩评论