Name

maxLength — NN n/a IE 4 DOM n/a

Synopsis

Read/Write

The maximum number of characters that may be typed into a text INPUT element. In practice, browsers beep or otherwise alert users when a typed character would exceed the maxLength value. There is no innate correlation between the maxLength and size properties. If the maxLength allows for more characters than fit within the specified width of the element, the browser provides horizontal scrolling (albeit awkward for many users) to allow entry and editing of the field.

Example

document.entryForm.myText.maxLength = 35

Value

Positive integer value.

Default

Unlimited.

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.