<input> - password


HTML DOM Password object


Password object

The Password object represents the password field in the HTML form.

Each time the HTML <input type="password"> tag appears on the form, a Password object is created.

This text input field is for the user to enter some sensitive data, such as passwords, etc. When the user is typing, his input is masked (eg using an asterisk *) to prevent people next to him from seeing the input from behind him. Note, however, that when the form is submitted, the input is sent in clear text.

Similar to elements of type "text", it fires the onchange event handler when the user changes the displayed value.

You can access the password field by iterating over the form's elements[] array, or by using document.getElementById().


Password Object Properties

W3C: W3C standard.

AttributeDescriptionW3C
defaultValueSets or returns the default value for the password field.Yes
disabledSets or returns whether the Password field should be disabled.Yes
formReturns a reference to the form that contains this password field.Yes
maxLengthSets or returns the maximum number of characters in a password field.Yes
nameSets or returns the name of the password field.Yes
readOnlySets or returns whether the password field should be read-only.Yes
sizeSets or returns the length of the password field.Yes
typeReturns the form element type for the password field.Yes
valueSets or returns the value of the value property of the password field.Yes

Password object methods

MethodDescriptionW3C
select()Select the text in the password field.Yes

Standard Properties and Events

Password objects also support standard properties and events .