本文根据 Devhints / Input tag 翻译。代码示例及版本范围沿用原文。原文标注更新日期:2017-10-30。
输入
<input ...
disabled
required
checked
autofocus
autocomplete='off' <!-- autocomplete -->
autocompletetype='cc-exp'
autocapitalize='off' <!-- for mobiles -->
pattern='\d*' <!-- force numeric input in iOS -->
Input 类型
文本
- hidden
- password
- tel
- text
- search
时间
- date
- time
Time(支持度不高)
- month
- week
- datetime
- datetime-local
其他
- file
- radio
- checkbox
按钮
- button
- reset
- submit
- 图像 (image)
数值型
- number
- range
示例
日期
| 类型 (Type) | 示例 |
|---|---|
type='date' | |
type='time' |
日期时间
| 类型 (Type) | 示例 |
|---|---|
type='datetime' | |
type='datetime-local' |
datetime 以及 datetime-local 相关字段的支持度不高。
数字
| 类型 (Type) | 示例 |
|---|---|
type='number' | |
type='range' |
文本
| 类型 (Type) | 示例 |
|---|---|
type='text' | |
type='password' | |
type='search' | |
type='tel' |