maxlength attribute for input and textarea elements
Declares an upper bound on the number of characters the user can input. Normally the UI ignores attempts by the user to type in additional characters beyond this limit.
IE | Edge | Firefox | Chrome | Safari | Opera | iOS Safari | Opera Mini | Android Browser | Blackberry Browser | Opera Mobile | Chrome for Android | Firefox for Android | IE Mobile | UC Browser for Android | Samsung Internet | QQ Browser | Baidu Browser |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
49 | |||||||||||||||||
56 | 9.3 | 4.4 | |||||||||||||||
14
See notes:
|
52 | 57 | 10 | 10.0-10.2 | 4.4.3-4.4.4 | 4 | |||||||||||
11 | 15
See notes:
|
53 | 58 | 10.1 | 44 | 10.3 | all
See notes:
|
56 | 10 | 37
See notes:
|
57 | 52 | 11 | 11.4
See notes:
|
5 | 1.2 | 7.12 |
54 | 59 | TP | 45 | ||||||||||||||
55 | 60 | 46 | |||||||||||||||
56 | 61 |
Notes
-
1
<textarea>
's' UI does not prevent the user from typing additional characters beyond themaxlength
limit. -
2
Does not support the
HTMLTextAreaElement.maxLength
DOM property. -
3
Does not support
ValidityState.tooLong
. In some cases, this is because.validity
is not supported in the first place. -
4
Does not support
ValidityState.tooLong
correctly in the (unlikely) case of the value being initially set too long, then changed by the user to a still incorrect state. See Firefox bug and MS Edge bug. -
5
<input>
's UI does not prevent the user from typing additional characters beyond themaxlength
limit between two existing characters of the string. -
6
Allows text beyond maxlength to be entered at first, but removes all characters past the maxlength when focus is lost.