Latest web development tutorials

HTML DOM Password objects

Password objects

Password object represents an HTML form in the password field.

HTML's <input type = "password"> tag on every once in a form, a Password object is created.

The text entry field for the user to enter certain sensitive data, such as passwords. When the user enters his input is (for example, use an asterisk *), in order to prevent the person next to see the contents of the masked input from behind him. But note that when the form is submitted, the input is sent in the clear.

And element type of "text" Similarly, when the user changes the display value, it will trigger the onchange event handler.

You can [] array to access the password field by traversing form elements, or by using document.getElementById ().


Password object properties

W3C: W3C standards.

属性 描述 W3C
defaultValue 设置或返回密码字段的默认值。 Yes
disabled 设置或返回是否应被禁用密码字段。 Yes
form 返回对包含此密码字段的表单的引用。 Yes
maxLength 设置或返回密码字段中字符的最大数目。 Yes
name 设置或返回密码字段的名称。 Yes
readOnly 设置或返回密码字段是否应当是只读的。 Yes
size 设置或返回密码字段的长度。 Yes
type 返回密码字段的表单元素类型。 Yes
value 设置或返回密码字段的 value 属性的值。 Yes

Password object methods

方法 描述 W3C
select() 选取密码字段中的文本。 Yes

Standard properties and events

Password objects also supports the standard attributes and events .