当前位置: 首页 > 网络学院 > 客户端脚本教程 > HTML DOM > DOM Input Password 对象
The Password object represents a password field in an HTML form. For each instance of an HTML <input type="password"> tag on a form, a Password object is created.
当HTML表单中含有<input type="password">标签就意味着Password对象建立起来了
You can access a Password object by indexing the elements array (by number or name) of the corresponding form or by using getElementById().
你可以根据表单的元素组索引数或名称来访问Password对象,也可以使用getElementById()来访问
IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).
Property 属性 | Description 描述 | IE | F | N | W3C |
---|---|---|---|---|---|
accept | Sets or returns a list of content types, which the server processing this form will handle correctly 设置或返回内容类型列表,服务器可以更准确的处理这个表单 | - | Yes | ||
accesskey | Sets or returns the keyboard key to access the password field 设置或返回可以访问password field的键盘按键。 | 4 | Yes | ||
defaultValue | Sets or returns the initial value of the password field 设置或返回password field的初始值 | 3 | 1 | 2 | Yes |
disabled | Sets or returns whether or not the password field should be disabled 设置或返回password field是否可用 | 5 | 1 | 6 | Yes |
form | Returns a reference to the password field's parent form 返回password field的父表参考 | 3 | 1 | 2 | Yes |
id | Sets or returns the id of the password field (In IE 4 this property is read-only) 设置或返回password field的id | 4 | 1 | No | |
maxLength | Sets or returns the maximum number of characters the user can enter in the password field 设置后返回password field里可输入的最大限度字符数 | 4 | 1 | 6 | Yes |
name | Sets or returns the name of the password field 设置或返回password field的name | 3 | 1 | 2 | Yes |
readOnly | Sets or returns whether the content of the password field is read-only 设置或返回password field里的内容为只读 | 4 | 1 | 6 | Yes |
size | Sets or returns the size of the password field 设置或返回password field的大小 | 3 | 1 | 6 | Yes |
tabIndex | Sets or returns the index that defines the tab order for the password field 设置或返回password field的tab顺序 | 4 | Yes | ||
type | The type of the form element. For a password object it will always be "password" 表单元素类型。password 对象就显示为"password" | 3 | 1 | 3 | Yes |
value | Sets or returns the value of the value attribute of the password field 设置或返回password field的value属性值 | 3 | 1 | 2 | Yes |
Method 方法 | Description 描述 | IE | F | N | W3C |
---|---|---|---|---|---|
blur() | Removes focus from the password field 取消对password field的聚焦 | 4 | 1 | 2 | Yes |
click() | Simulates a mouse-click on the password field 模拟鼠标点击password field | 4 | 1 | No | |
focus() | Sets focus on the password field 让password field获得聚焦 | 3 | 1 | 2 | Yes |
select() | Selects and highlights the entire text that is in the password field 选中password field里的文字并且显示高亮 | 4 | 1 | 2 | Yes |
Syntax: object.event_name="someJavaScriptCode"
语法:对象.事件名称="一些JS代码"
Event 事件 | Description 描述 | IE | F | N | W3C |
---|---|---|---|---|---|
onBlur | Executes some code when the password field loses focus 当password field失去聚焦的时候执行代码 | 4 | 1 | 2 | |
onClick | Executes some code when the user clicks in the password field 当用户点击password field的时候执行代码 | 4 | |||
onFocus | Executes some code when the password field gets focus 当password field得到聚焦的时候执行一些代码 | 3 | 1 | 2 | |
onKeyDown | Executes some code when a key is pressed down in the password field 当在password field中按住某键的时候执行代码 | 4 | 1 | 4 | |
onKeyPress | Executes some code when an alphanumeric key is pressed in the password field 当在password field中按下并释放某键的时候执行一些代码 | 4 | 1 | 4 | |
onKeyUp | Executes some code when a key is released in the password field 当在password field中释放某键的时候执行一些代码 | 4 | 1 | 4 | |
onSelectStart | Executes some code when some text in the password field is selected 当password field中的文字选中时执行一些代码 | 4 |