开发者

HTML5 textarea character limit attribute

开发者 https://www.devze.com 2023-02-24 11:25 出处:网络
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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消