HTML DOM Input Password 對象
- 上一頁 <input> number
- 下一頁 <input> radio
Input Password 對象
Input Password 對象表示帶有 type="password" 的 HTML <input> 元素。
訪問 Input Password 對象
您可以使用 getElementById() 訪問 type="password" 的 <input> 元素:
var x = document.getElementById("myPsw");
提示:您還可以通過搜索表單的 elements 集合 來訪問 <input type="password">。
創建 Input Password 對象
您可以使用 document.createElement() 方法創建 type="password" 的 <input> 元素:
var x = document.createElement("INPUT"); x.setAttribute("type", "password");
Input Password 對象屬性
屬性 | 描述 |
---|---|
autocomplete | 設置或返回密碼字段的 autocomplete 屬性值。 |
autofocus | 設置或返回頁面加載時密碼字段是否應自動獲得焦點。 |
defaultValue | 設置或返回密碼字段的默認值。 |
disabled | 設置或返回是否禁用密碼字段。 |
form | 返回對包含密碼字段的表單的引用。 |
maxLength | 設置或返回密碼字段的 maxlength 屬性值。 |
name | 設置或返回密碼字段的 name 屬性值。 |
pattern | 設置或返回密碼字段的 pattern 屬性值。 |
placeholder | 設置或返回密碼字段的 placeholder 屬性值。 |
readOnly | 設置或返回密碼字段是否為只讀。 |
required | 設置或返回在提交表單之前是否必須填寫密碼字段。 |
size | 設置或返回密碼字段的 size 屬性值。 |
type | 返回密碼字段是哪種類型的表單元素。 |
value | 設置或返回密碼字段的 value 屬性值。 |
Input Password 對象方法
方法 | 描述 |
---|---|
select() | 選取密碼字段的內容。 |
- 上一頁 <input> number
- 下一頁 <input> radio