HTML DOM Password Object
Password Object
The Password object represents a password field in an HTML form.
The HTML tag creates a Password object each time it appears in a form.
This text input field is for users to enter sensitive data, such as passwords. When the user types, the input is masked (for example, with asterisks *), to prevent people nearby from seeing what is typed. Note, however, that the input is sent in plain text when the form is submitted.
Similar to an element of type "text", it triggers the onchange event handler when the user changes the displayed value.
You can access the password field by iterating over the elements[] array of the form, or by using document.getElementById().
Password Object Properties
W3C: W3C standard.
| property | Description | W3C |
|---|---|---|
| defaultValue | Sets or returns the default value of the password field. | Yes |
| disabled | Sets or returns whether the password field should be disabled. | Yes |
| form | Returns a reference to the form containing this password field. | Yes |
| maxLength | Sets or returns the maximum number of characters in the password field. | Yes |
| name | Sets or returns the name of the password field. | Yes |
| readOnly | Sets or returns whether the password field should be read-only. | Yes |
| size | Sets or returns the length of the password field. | Yes |
| type | Returns the form element type of the password field. | Yes |
| value | Sets or returns the value of the value attribute of the password field. | Yes |
Password Object Methods
| Method | Description | W3C |
|---|---|---|
| select() | Selects the text in the password field. | Yes |
Standard properties and events
The Password object also supports the standard property and Events.