HTML DOM Input Password Object

Input Password object

The Input Password object represents an HTML <input> element with type="password".

Access Input Password object

You can access the <input> element with type="password" using getElementById():

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

Try It Yourself

Tip:You can also search the form by elements collection To access <input type="password">.

Create Input Password object

You can create an <input> element with type="password" using the document.createElement() method:

var x = document.createElement("INPUT");
x.setAttribute("type", "password");

Try It Yourself

Input Password Object Properties

Attributes Description
autocomplete Sets or returns the autocomplete attribute value of the password field.
autofocus Sets or returns whether the password field should automatically focus when the page is loaded.
defaultValue Sets or returns the default value of the password field.
disabled Sets or returns whether the password field is disabled.
form Returns a reference to the form containing the password field.
maxLength Sets or returns the maxlength attribute value of the password field.
name Sets or returns the name attribute value of the password field.
pattern Sets or returns the pattern attribute value of the password field.
placeholder Sets or returns the placeholder attribute value of the password field.
readOnly Sets or returns whether the password field is read-only.
required Sets or returns whether the password field must be filled out before submitting the form.
size Sets or returns the size attribute of the password field.
type Returns what type of form element the password field is.
value Sets or returns the value attribute of the password field.

Input Password Object Methods

Method Description
select() Select the content of the password field.

Standard Attributes and Events

The Input Password object supports both standardsAttributesAndEvents.

Related Pages

HTML Tutorial:HTML Form

HTML Reference Manual:HTML <input> Tag

HTML Reference Manual:HTML <input> type Attribute