maxLength · WebPlatform Docs

Summary

The maxLength attribute sets an upper limit on the number of characters that can be entered in an input element.

Applies to [html/elements/input](/html/elements/input)

This attribute can be applied to inputs with the type [text](/html/elements/input/type/text), [search](/html/elements/input/type/search), [url](/html/elements/input/type/url), [email](/html/elements/input/type/email), [telephone](/html/elements/input/type/telephone), and [password](/html/elements/input/type/password).

Examples

The example text box has a max length of 12 characters.

<input maxLength="12">

View live example

See also

Related articles

HTML

Attributions