Input Password maxLength Attribute

Definition and Usage

maxLength Set or return the value of the maxLength attribute of the password field.

The HTML maxlength attribute specifies the maximum number of allowed characters in the password field.

Tip:To set or return the width of the password field (in characters), use size attribute.

See also:

HTML Reference Manual:HTML <input> maxlength-Eigenschaft

Example

Example 1

Get the maximum number of allowed characters in the specified password field:

var x = document.getElementById("myPsw").maxLength;

Try it yourself

Example 2

Set the maximum number of allowed characters in the password field:

document.getElementById("myPsw").maxLength = "10";

Try it yourself

Syntax

Return the maxLength attribute:

passwordObject.maxLength

Set the maxLength attribute:

passwordObject.maxLength = integer

Attributwert

Wert Beschreibung
integer Gibt die maximale Anzahl der zulässigen Zeichen im Passwortfeld an.

Technische Details

Rückgabewert: Zahl, die die maximale Anzahl der zulässigen Zeichen im Passwortfeld angibt.

Browser-Unterstützung

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Unterstützung Unterstützung Unterstützung Unterstützung Unterstützung