Input Password size Property

❮ Input Password Object

Example

Change the width of a password field:

document.getElementById("myPsw").size = "50";
Try it Yourself »

Description

The size property sets or returns the size attribute of a password field.

The size attribute specifies the width of a password field (in number of characters).

The default value is 20.

Tip: To set or return the maximum number of characters allowed in the password field, use the maxLength property.


Browser Support

Property
size Yes 10.0 Yes Yes Yes

Syntax

Return the size property:

passwordObject.size

Set the size property:

passwordObject.size = number

Property Values

Value Description
number Specifies the width of the password field, in characters. Default value is 20

Technical Details

Return Value: A Number, representing the width of the password field, in characters

More Examples

Example

Get the width of a password field:

var x = document.getElementById("myPsw").size;
Try it Yourself »

Related Pages

HTML reference: HTML <input> size attribute


❮ Input Password Object
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.