THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Input Password maxLength Property

Input Password Object Reference Input Password Object

Example

Get the maximum number of characters allowed in a specific password field:

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

The result of x will be:

8
Try it yourself »

Definition and Usage

The maxLength property sets or returns the value of the maxlength attribute of a password field.

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

Tip: To set or return the width of a password field, in number of characters, use the size property.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The maxLength property is supported in all major browsers.


Syntax

Return the maxLength property:

passwordObject.maxLength

Set the maxLength property:

passwordObject.maxLength=integer

Property Values

Value Description
integer Specifies the maximum number of characters allowed in the password field

Technical Details

Return Value: A Number, representing the maximum number of characters allowed in the password field

More Examples

Example

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

document.getElementById("myPsw").maxLength = "10";
Try it yourself »

Related Pages

HTML reference: HTML <input> maxlength attribute


Input Password Object Reference Input Password Object