cheatsheets/html-input.md

112 lines
1.6 KiB
Markdown
Raw Permalink Normal View History

2014-07-30 05:53:29 +00:00
---
2015-11-24 05:02:17 +00:00
title: Input tag
category: HTML
2020-07-04 13:33:09 +00:00
updated: 2017-10-30
2017-10-29 11:59:18 +00:00
weight: -3
2014-07-30 05:53:29 +00:00
---
2017-10-29 11:59:18 +00:00
### Input
2014-07-30 05:53:29 +00:00
2017-10-29 11:59:18 +00:00
```html
<input ...
disabled
required
checked
```
2014-07-30 05:53:29 +00:00
2017-10-29 11:59:18 +00:00
```html
autofocus
```
```html
autocomplete='off' <!-- autocomplete -->
autocompletetype='cc-exp'
autocapitalize='off' <!-- for mobiles -->
pattern='\d*' <!-- force numeric input in iOS -->
```
2014-07-30 05:53:29 +00:00
### Input types
2017-10-29 11:59:18 +00:00
#### Text
* email
* hidden
* **password**
* tel
* **text**
* search
{: .-four-column}
#### Time
* date
* time
{: .-four-column}
#### Time (not widely supported)
* month
* week
* datetime
* datetime-local
{: .-four-column}
#### Etc
* **file**
* **radio**
* **checkbox**
{: .-four-column}
#### Buttons
* button
* reset
* submit
* image
{: .-four-column}
#### Numeric
* number
* range
{: .-four-column}
## Examples
2014-07-30 05:53:29 +00:00
2017-10-29 11:59:18 +00:00
### Dates
2014-07-30 05:53:29 +00:00
2017-10-29 11:59:18 +00:00
| Type | Example |
| --- | --- |
| `type='date'` | <input type='date'> |
| `type='time'` | <input type='time'> |
2014-07-30 05:53:29 +00:00
2017-10-29 16:10:44 +00:00
### Datetime
2014-07-30 05:53:29 +00:00
2017-10-29 11:59:18 +00:00
| Type | Example |
| --- | --- |
| `type='datetime'` | <input type='datetime'> |
| `type='datetime-local'` | <input type='datetime-local'> |
2014-07-30 05:53:29 +00:00
2017-10-29 11:59:18 +00:00
`datetime` and `datetime-local` fields are not widely supported.
2014-07-30 05:53:29 +00:00
2017-10-29 11:59:18 +00:00
### Numbers
2014-07-30 05:53:29 +00:00
2017-10-29 11:59:18 +00:00
| Type | Example |
| --- | --- |
| `type='number'` | <input type='number'> |
| `type='range'` | <input type='range'> |
2014-07-30 05:53:29 +00:00
2017-10-29 11:59:18 +00:00
### Text
2014-07-30 05:53:29 +00:00
2017-10-29 11:59:18 +00:00
| Type | Example |
| --- | --- |
| `type='text'` | <input type='text'> |
| `type='password'` | <input type='password'> |
| `type='search'` | <input type='search'> |
| `type='tel'` | <input type='tel'> |
2014-07-30 05:53:29 +00:00
2017-10-29 11:59:18 +00:00
## Also see
2014-07-30 05:53:29 +00:00
2017-10-29 11:59:18 +00:00
* <https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input>