` tag in a form,"> ` tag in a form," />
Easy Tutorial
❮ Met Text Select Prop Element Nextelementsibling ❯

HTML DOM


Password Object

The Password object represents a password field in an HTML form.

For each occurrence of the <input type="password"> tag in a form, a Password object is created.

This text input field is used for users to enter sensitive data, such as passwords. As the user types, their input is masked (e.g., with asterisks *) to prevent others from seeing it over their shoulder. However, it's important to note that the input is sent in plain text when the form is submitted.

Similar to elements of type "text", it triggers the onchange event handler when the displayed value is changed by the user.

You can access the password field by traversing the form's elements[] array 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 that contains this password field. Yes
maxLength Sets or returns the maximum number of characters allowed 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 size of the password field. Yes
type Returns the type of the form element for 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 standard properties and events.

❮ Met Text Select Prop Element Nextelementsibling ❯