aboutsummaryrefslogtreecommitdiff
path: root/files/uk/web/html/element/input
diff options
context:
space:
mode:
Diffstat (limited to 'files/uk/web/html/element/input')
-rw-r--r--files/uk/web/html/element/input/date/index.html510
-rw-r--r--files/uk/web/html/element/input/datetime-local/index.html543
-rw-r--r--files/uk/web/html/element/input/index.html753
3 files changed, 1806 insertions, 0 deletions
diff --git a/files/uk/web/html/element/input/date/index.html b/files/uk/web/html/element/input/date/index.html
new file mode 100644
index 0000000000..1737d7786a
--- /dev/null
+++ b/files/uk/web/html/element/input/date/index.html
@@ -0,0 +1,510 @@
+---
+title: <input type="date">
+slug: Web/HTML/Element/input/date
+translation_of: Web/HTML/Element/input/date
+---
+<div>{{HTMLRef}}</div>
+
+<p><span class="seoSummary">{{HTMLElement("input")}} елементи типу <strong><code>date</code></strong> створюють поле вводу дати з вбудованим інтерфейсом вибору.</span> Результатом вибору будуть рік, місяць та день, без часу. <code><a href="/en-US/docs/Web/HTML/Element/input/time">time</a></code> та <code><a href="/en-US/docs/Web/HTML/Element/input/datetime-local">datetime-local</a></code> поля підтримують вибір часу та дати і часу.</p>
+
+<div>{{EmbedInteractiveExample("pages/tabbed/input-date.html", "tabbed-shorter")}}</div>
+
+<p class="hidden">Ісходний код цих прикладів зберігається на GitHub. Якщо ви хотілиби присвятити час розвитку данних прикладів, клонуйте <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> і відправте нам pull-запит.</p>
+
+<p>UI віджет змінюється від оглядача к оглядачу; для перегляду сумісності дивіться {{anch("Browser compatibility")}}. Якщо оглядач не підтримує такий віджет, він буде відображений просто як <code><a href="/en-US/docs/Web/HTML/Element/input/text">&lt;input type="text"&gt;.</a></code></p>
+
+<p>Серед оглядачів які підтримуюсь кастомний інтерфейс вибору дати є Chrome/Opera, який виглядає наступним чином:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/14909/date-picker-chrome.png" style="display: block; height: 220px; margin: 0px auto; width: 275px;"></p>
+
+<p>Edge вибор дати виглядає так:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/14911/date-picker-edge.png" style="display: block; margin: 0 auto;"></p>
+
+<p>У Firefox вибір дати буде таким:</p>
+
+<p><img alt="Datepicker UI in firefox" src="https://mdn.mozillademos.org/files/15644/firefox_datepicker.png" style="display: block; margin: 0 auto;"></p>
+
+<table class="properties">
+ <tbody>
+ <tr>
+ <td><strong>{{anch("Value")}}</strong></td>
+ <td>{{domxref("DOMString")}} представляє дату у YYYY-MM-DD форматі, або пустим</td>
+ </tr>
+ <tr>
+ <td><strong>Події</strong></td>
+ <td>{{event("change")}} та {{event("input")}}</td>
+ </tr>
+ <tr>
+ <td><strong>Підримка атрибутів</strong></td>
+ <td>{{htmlattrxref("autocomplete", "input")}}, {{htmlattrxref("list", "input")}}, {{htmlattrxref("readonly", "input")}}, та {{htmlattrxref("step", "input")}}</td>
+ </tr>
+ <tr>
+ <td><strong>IDL атрибути</strong></td>
+ <td><code>list</code>, <code>value</code>, <code>valueAsDate</code>, <code>valueAsNumber</code>.</td>
+ </tr>
+ <tr>
+ <td><strong>Методи</strong></td>
+ <td>{{domxref("HTMLInputElement.select", "select()")}}, {{domxref("HTMLInputElement.stepDown", "stepDown()")}}, {{domxref("HTMLInputElement.stepUp", "stepUp()")}}</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Значення">Значення</h2>
+
+<p>{{domxref("DOMString")}} представляє значення дати введенної у input. Формат дати описаний у {{SectionOnPage("/en-US/docs/Web/HTML/Date_and_time_formats", "Format of a valid date string")}}.</p>
+
+<p>Ви можете встановити значення за замовчуванням встановивши дату в атрибут {{htmlattrxref("value", "input")}} , наприклад:</p>
+
+<pre class="brush: html">&lt;input id="date" type="date" value="2017-06-01"&gt;</pre>
+
+<p>{{EmbedLiveSample('Value', 600, 40)}}</p>
+
+<p>Треба пам'ятати що відображений формат відрізняється від актуального <code>value</code> — відображення формату дати буде вибрано на основі вибраної локалі користувальницького оглядача, тоді як <code>value</code> дати завжди є у форматі <code>yyyy-mm-dd</code>.</p>
+
+<p>Ви також можете взяти чи встановити значення дати у JavaScript використовуючи властивість елементу {{domxref("HTMLInputElement.value", "value")}} , наприклад:</p>
+
+<pre class="brush: js">var dateControl = document.querySelector('input[type="date"]');
+dateControl.value = '2017-06-01';</pre>
+
+<p>Цей код знаходить перший {{HTMLElement("input")}} елемент <code>type</code> якого є <code>date</code> і встановлює його значення 2017-06-01 (June 1, 2017).</p>
+
+<h2 id="Додаткові_атрибути">Додаткові атрибути</h2>
+
+<p>Додатково з загальними атрибутами {{HTMLElement("input")}} <code>"date"</code> надає наступні додаткові атрибути:</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Атрибут</th>
+ <th scope="col">Опис</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>{{anch("max")}}</code></td>
+ <td>Максимальна дата яка може бути введена</td>
+ </tr>
+ <tr>
+ <td><code>{{anch("min")}}</code></td>
+ <td>Мінімальна дата</td>
+ </tr>
+ <tr>
+ <td><code>{{anch("readonly")}}</code></td>
+ <td>Чи є у інпута контент чи нема, він лише для считування</td>
+ </tr>
+ <tr>
+ <td><code>{{anch("step")}}</code></td>
+ <td>Інтервал </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="htmlattrdef(max)">{{htmlattrdef("max")}}</h3>
+
+<p>Остання дата. Якщо встановлена дата {{htmlattrxref("value", "input")}} більше ніж ця дата, елемент не пройде <a href="/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation">constraint validation</a>. Якщо значення <code>max</code> не валідна строка формату <code>yyyy-MM-dd</code>, тоді елемент не буде мати максимальне обмеження.</p>
+
+<p>Це значення має вказувати дату пізнішу або поточну вказанному атрибуту <code>min</code>.</p>
+
+<h3 id="htmlattrdef(min)">{{htmlattrdef("min")}}</h3>
+
+<p>Мінімальна дата; дати раніші за вказану не пройдуть <a href="/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation">constraint validation</a>. Якщо значення  <code>min</code> атрибуту має неавлідний формат <code>yyyy-MM-dd</code>, тоді елемент не матиме мінімального обмеження.</p>
+
+<p>Це значення вказує меньшу або еквівалентну значенню атрибута <code>max</code>.</p>
+
+<p>{{page("/en-US/docs/Web/HTML/Element/input/text", "readonly", 0, 1, 2)}}</p>
+
+<h3 id="htmlattrdef(step)">{{htmlattrdef("step")}}</h3>
+
+<p>{{page("/en-US/docs/Web/HTML/Element/input/number", "step-include")}}</p>
+
+<p>Для <code>date</code> інпутів, значення <code>step</code> вказується в днях, скалярні до 86,400,000 (мілісекунди). За замовчуванная <code>step</code> має 1, означаюче 1 день.</p>
+
+<div class="blockIndicator note">
+<p>Вказання <code>any</code> для <code>step</code> атрибуту робить той самий ефект як і <code>1</code>.</p>
+</div>
+
+<h2 id="Використання_date_інпутів">Використання date інпутів</h2>
+
+<p>Поле введення дати зручні на перший погляд — вони надають легкий UI(користувальницький інтерфейс) для вибору дати, і нормалізують формат даних для відправки на сервер, незважаючи на локаль користувача. Однак, існують проблеми підтримки деякими оглядачами <code>&lt;input type="date"&gt;</code>.</p>
+
+<p>Подивимось на базові та комлексні використання <code>&lt;input type="date"&gt;</code>, щодо сумісності оглядачів ви можете порадитись за посиланням (see {{anch("Handling browser support")}}). Звичайно, з часом підтримка в оглядачах розповсюдиться. і усі проблеми будуть вирішені.</p>
+
+<h3 id="Базові_використання_date">Базові використання date</h3>
+
+<p>Найпростіше використання <code>&lt;input type="date"&gt;</code> передбачає базову <code>&lt;input&gt;</code> і {{htmlelement("label")}} комбінацію елементів, як бачимо нижче:</p>
+
+<pre class="brush: html">&lt;form&gt;
+ &lt;div&gt;
+ &lt;label for="bday"&gt;Enter your birthday:&lt;/label&gt;
+ &lt;input type="date" id="bday" name="bday"&gt;
+ &lt;/div&gt;
+&lt;/form&gt;</pre>
+
+<p>{{EmbedLiveSample('Basic_uses_of_date', 600, 40)}}</p>
+
+<h3 id="Встановлення_мінімальной_і_максимальної_дати">Встановлення мінімальной і максимальної дати</h3>
+
+<p>Ви можете використовувати {{htmlattrxref("min", "input")}} і {{htmlattrxref("max", "input")}} атрибути щоб обмежити дати які будуть вибрані користувачем. В наступному прикладі ми встановлюємо мінімальну дату <code>2017-04-01</code> і максимальну дату <code>2017-04-30</code>:</p>
+
+<pre class="brush: html">&lt;form&gt;
+ &lt;div&gt;
+ &lt;label for="party"&gt;Choose your preferred party date:&lt;/label&gt;
+ &lt;input type="date" id="party" name="party" min="2017-04-01" max="2017-04-30"&gt;
+ &lt;/div&gt;
+&lt;/form&gt;</pre>
+
+<p>{{EmbedLiveSample('Setting_maximum_and_minimum_dates', 600, 40)}}</p>
+
+<p>Результатом будуть лише дні в Квітні 2017го які можно буде вибрати — тільки "дні", частина текстового значення будуть можливі для зміни, дати поза Квітнем не будуть проскролюватись у віджеті.</p>
+
+<div class="note">
+<p><strong>Примітка</strong>: Ви можете використати {{htmlattrxref("step", "input")}} атрибут для того щоб вказати інтервал зміни днів (наприклад ви хотіли б щоб можно були вибрати лише Неділю). Однак, це не завжди ефективно в тих чи іншіх реалізаціях.</p>
+</div>
+
+<h3 id="Контроль_розміру_input">Контроль розміру input</h3>
+
+<p><code>&lt;input type="date"&gt;</code> не підтримує розмір форми атрибутами наприклад {{htmlattrxref("size", "input")}}. Зверніться до <a href="/en-US/docs/Web/CSS">CSS</a> для контролю розміру елементу.</p>
+
+<h2 id="Валідація">Валідація</h2>
+
+<p>За замовчуванням, <code>&lt;input type="date"&gt;</code> не додає жодної валідації на введення значення. UI реалізація загалом не дозволяє уведення будь чого що не є датою — що є добре — але ви всеодно можете лишати поле пустим чи (в оглядачах де інпут відображається простим типом <code>text</code>) ввести неправильну дату (наприклад 32ге Квітня).</p>
+
+<p>Якщо ви використовуєте {{htmlattrxref("min", "input")}} і {{htmlattrxref("max", "input")}} для обмеження введення дат (дивіться {{anch("Setting maximum and minimum dates")}}), підтримуючі оглядачі відобразять помилку якщо ви спробуєте відправити дату поза меж вказаних в атрибутах. Однак, перевірте результат щоб запевнитись що значення всередені цих дат, тому що вони можуть не підтримуватись пристрієм користувача.</p>
+
+<p>В додаток, ви можете використовувати {{htmlattrxref("required", "input")}} атрибут щоб зробити заповнення дати обьв'язковим — знову ж, буде відображена помилка якщо користувач захоче відправити пусте поле. Принаймні, це буде працювати у більшості оглядачів.</p>
+
+<p>Давайте розглянемо приклад — ми встановили мінімальну і максимальну дату, і також зробили його обов'язковим:</p>
+
+<pre class="brush: html">&lt;form&gt;
+ &lt;div&gt;
+ &lt;label for="party"&gt;Choose your preferred party date (required, April 1st to 20th):&lt;/label&gt;
+ &lt;input type="date" id="party" name="party" min="2017-04-01" max="2017-04-20" required&gt;
+ &lt;span class="validity"&gt;&lt;/span&gt;
+ &lt;/div&gt;
+ &lt;div&gt;
+ &lt;input type="submit"&gt;
+ &lt;/div&gt;
+&lt;/form&gt;</pre>
+
+<p>Якщо ви спробуєте відправити форму з незаповненою датою(або з датою поза межами), оглядач відобразить помилку. Спробуйте це самі зробити для перевірки:</p>
+
+<p>{{EmbedLiveSample('Validation', 600, 100)}}</p>
+
+<p>Це скріншот приклади оглядача без підтримки віджету дати:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/14913/date-picker-chrome-error-message.png" style="border-style: solid; border-width: 1px; display: block; margin: 0px auto;"></p>
+
+<p>CSS використаний нижче в прикладі. Ми використовуєм правила {{cssxref(":valid")}} та {{cssxref(":invalid")}} CSS щоб стилізувати відображення валідного чи невалідного введенного значення поля. Ми встановлюємо іконку на {{htmlelement("span")}} біля інпуту, не на самий інпут, тому що у Chrome створений контент розміщений всередені контролю форми, і не може бути застилізований чи відображений коректно.</p>
+
+<pre class="brush: css">div {
+ margin-bottom: 10px;
+ display: flex;
+ align-items: center;
+}
+
+label {
+ display: inline-block;
+ width: 300px;
+}
+
+input:invalid+span:after {
+ content: '✖';
+ padding-left: 5px;
+}
+
+input:valid+span:after {
+ content: '✓';
+ padding-left: 5px;
+}</pre>
+
+<div class="warning">
+<p><strong>Важливо</strong>: HTML валідація форми не замінює скрипти які перевіряють чи буле введена інформація у коректному форматі. Це достатньо простий метод щоб додати корекцію до HTML, їх можливо обійти , чи видалити зовсім. Якщо ваша серверна сторона не перевірить відправлені данні, це може бути катастрофа (данні можуть бути дуже великого розміру, або неправильного типу, вам можуть завантажити скрипт взлому і так далі).</p>
+</div>
+
+<h2 id="Обробка_підтримки_оглядачів">Обробка підтримки оглядачів</h2>
+
+<p>Як згадано раніше, більша частина проблем з використанням інпуту дати описани  у {{anch("Browser compatibility", "browser support")}}. Як приклад, дата пікер у Firefox для Android виглядає так:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/14915/date-picker-fxa.png" style="display: block; margin: 0 auto;"></p>
+
+<p>Непідтримуючи оглядачі точно деградують інпут, це створює проблеми у якості інтерфейсу користувача (представлеий віджет буде іншим), і обробкою даних.</p>
+
+<p>Наступна проблема це більш серьозна; як згадували раніше, за інпутом дати, данні завжди нормалізуються у формат <code>yyyy-mm-dd</code>. З текстовим інпутом оглядач не підтримує формат введених даних, і є багато прикладів як люди вводять дати, наприклад:</p>
+
+<ul>
+ <li><code>ddmmyyyy</code></li>
+ <li><code>dd/mm/yyyy</code></li>
+ <li><code>mm/dd/yyyy</code></li>
+ <li><code>dd-mm-yyyy</code></li>
+ <li><code>mm-dd-yyyy</code></li>
+ <li><code>Month dd yyyy</code></li>
+</ul>
+
+<p>Єдиний спосіб стосовно цього є лише введення атрибуту {{htmlattrxref("pattern", "input")}}. Якщо інпут дати не використовує цей атрибут, то текстовий буде. Наприклад, розгляньте код у непідтримуючих оглядачах:</p>
+
+<pre class="brush: html">&lt;form&gt;
+ &lt;div&gt;
+ &lt;label for="bday"&gt;Enter your birthday:&lt;/label&gt;
+ &lt;input type="date" id="bday" name="bday" required pattern="[0-9]{4}-[0-9]{2}-[0-9]{2}"&gt;
+ &lt;span class="validity"&gt;&lt;/span&gt;
+ &lt;/div&gt;
+ &lt;div&gt;
+ &lt;input type="submit"&gt;
+ &lt;/div&gt;
+&lt;/form&gt;</pre>
+
+<p>{{EmbedLiveSample('Handling_browser_support', 600, 100)}}</p>
+
+<p>Якщо ви спробуєте відправити це, ви побачете помилку (інпут підсвітеться як невалідний) якщо ви ввели данні які не збігаються з шаблоном <code>nnnn-nn-nn</code>, де <code>n</code> номер від 0 до 9. Звичайно, це не зупинить людей від введення неправильної дати, чи введення у неправильному форматі, як <code>yyyy-dd-mm</code> (де ми очикуємо <code>yyyy-mm-dd</code>). Тож всеж таки маємо проблему.</p>
+
+<div class="hidden">
+<pre class="brush: css">div {
+ margin-bottom: 10px;
+}
+
+input:invalid + span {
+ position: relative;
+}
+
+input:invalid + span:after {
+ content: '✖';
+ position: absolute;
+ right: -18px;
+}
+
+input:valid + span {
+ position: relative;
+}
+
+input:valid + span:after {
+ content: '✓';
+ position: absolute;
+ right: -18px;
+}</pre>
+</div>
+
+<p>Найкращий шлях опрацьовувати дати в формах в крос-браузерному форматі на даний момент є введення користувачем дня, місяця, і року в окремих елементах ({{htmlelement("select")}}; (дивіться далі реалізацію), або використовуючи JavaScript бібліотеку <a href="https://jqueryui.com/datepicker/">jQuery date picker</a>.</p>
+
+<h2 id="Приклади">Приклади</h2>
+
+<p>В цьому прикладі ми створюємо два набори UI елементів для вибору дат: рідний <code>&lt;input type="date"&gt;</code> і набір із трьох {{htmlelement("select")}} елементів для вибору дати в тих оглядачах які не підтримують рідний date інпут.</p>
+
+<p>{{EmbedLiveSample('Examples', 600, 100)}}</p>
+
+<h3 id="HTML">HTML</h3>
+
+<p>HTML виглядає так:</p>
+
+<pre class="brush: html">&lt;form&gt;
+ &lt;div class="nativeDatePicker"&gt;
+ &lt;label for="bday"&gt;Enter your birthday:&lt;/label&gt;
+ &lt;input type="date" id="bday" name="bday"&gt;
+ &lt;span class="validity"&gt;&lt;/span&gt;
+ &lt;/div&gt;
+ &lt;p class="fallbackLabel"&gt;Enter your birthday:&lt;/p&gt;
+ &lt;div class="fallbackDatePicker"&gt;
+ &lt;span&gt;
+ &lt;label for="day"&gt;Day:&lt;/label&gt;
+ &lt;select id="day" name="day"&gt;
+ &lt;/select&gt;
+ &lt;/span&gt;
+ &lt;span&gt;
+ &lt;label for="month"&gt;Month:&lt;/label&gt;
+ &lt;select id="month" name="month"&gt;
+ &lt;option selected&gt;January&lt;/option&gt;
+ &lt;option&gt;February&lt;/option&gt;
+ &lt;option&gt;March&lt;/option&gt;
+ &lt;option&gt;April&lt;/option&gt;
+ &lt;option&gt;May&lt;/option&gt;
+ &lt;option&gt;June&lt;/option&gt;
+ &lt;option&gt;July&lt;/option&gt;
+ &lt;option&gt;August&lt;/option&gt;
+ &lt;option&gt;September&lt;/option&gt;
+ &lt;option&gt;October&lt;/option&gt;
+ &lt;option&gt;November&lt;/option&gt;
+ &lt;option&gt;December&lt;/option&gt;
+ &lt;/select&gt;
+ &lt;/span&gt;
+ &lt;span&gt;
+ &lt;label for="year"&gt;Year:&lt;/label&gt;
+ &lt;select id="year" name="year"&gt;
+ &lt;/select&gt;
+ &lt;/span&gt;
+ &lt;/div&gt;
+&lt;/form&gt;</pre>
+
+<p>Назви місяців жорстко закодовані (тому що вони завжди однакові), коли дні і роки динамічно згенеровані залежно від того який місяць і рік вибраний, і поточний рік (дивіться коментарі коду нижче для детального пояснення як ці функції працюють).</p>
+
+<div class="hidden">
+<pre class="brush: css">input:invalid+span:after {
+ content: '✖';
+ padding-left: 5px;
+}
+
+input:valid+span:after {
+ content: '✓';
+ padding-left: 5px;
+}</pre>
+</div>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<p>Друга частина коду розраховує чи підтримує оглядач <code>&lt;input type="date"&gt;</code>, ми створюєм {{htmlelement("input")}} елемент, із <code>type</code> <code>date</code>, потім одразу перевіряємо який тип було встановлено — непідтримуючі оглядачі автоматично повернуть тип <code>text</code>, тому що <code>date</code> тип автоматично перетворюється на <code>text</code>. Якщо <code>&lt;input type="date"&gt;</code> не підтримується, ми приховуємо рідний інпут і показуєм UI ({{htmlelement("select")}}) замість нього.</p>
+
+<pre class="brush: js">// define variables
+var nativePicker = document.querySelector('.nativeDatePicker');
+var fallbackPicker = document.querySelector('.fallbackDatePicker');
+var fallbackLabel = document.querySelector('.fallbackLabel');
+
+var yearSelect = document.querySelector('#year');
+var monthSelect = document.querySelector('#month');
+var daySelect = document.querySelector('#day');
+
+// hide fallback initially
+fallbackPicker.style.display = 'none';
+fallbackLabel.style.display = 'none';
+
+// test whether a new date input falls back to a text input or not
+var test = document.createElement('input');
+test.type = 'date';
+
+// if it does, run the code inside the if() {} block
+if(test.type === 'text') {
+ // hide the native picker and show the fallback
+ nativePicker.style.display = 'none';
+ fallbackPicker.style.display = 'block';
+ fallbackLabel.style.display = 'block';
+
+ // populate the days and years dynamically
+ // (the months are always the same, therefore hardcoded)
+ populateDays(monthSelect.value);
+ populateYears();
+}
+
+function populateDays(month) {
+ // delete the current set of &lt;option&gt; elements out of the
+ // day &lt;select&gt;, ready for the next set to be injected
+ while(daySelect.firstChild){
+ daySelect.removeChild(daySelect.firstChild);
+ }
+
+ // Create variable to hold new number of days to inject
+ var dayNum;
+
+ // 31 or 30 days?
+ if(month === 'January' || month === 'March' || month === 'May' || month === 'July' || month === 'August' || month === 'October' || month === 'December') {
+ dayNum = 31;
+ } else if(month === 'April' || month === 'June' || month === 'September' || month === 'November') {
+ dayNum = 30;
+ } else {
+ // If month is February, calculate whether it is a leap year or not
+ var year = yearSelect.value;
+ var isLeap = new Date(year, 1, 29).getMonth() == 1;
+ isLeap ? dayNum = 29 : dayNum = 28;
+ }
+
+ // inject the right number of new &lt;option&gt; elements into the day &lt;select&gt;
+ for(i = 1; i &lt;= dayNum; i++) {
+ var option = document.createElement('option');
+ option.textContent = i;
+ daySelect.appendChild(option);
+ }
+
+ // if previous day has already been set, set daySelect's value
+ // to that day, to avoid the day jumping back to 1 when you
+ // change the year
+ if(previousDay) {
+ daySelect.value = previousDay;
+
+ // If the previous day was set to a high number, say 31, and then
+ // you chose a month with less total days in it (e.g. February),
+ // this part of the code ensures that the highest day available
+ // is selected, rather than showing a blank daySelect
+ if(daySelect.value === "") {
+ daySelect.value = previousDay - 1;
+ }
+
+ if(daySelect.value === "") {
+ daySelect.value = previousDay - 2;
+ }
+
+ if(daySelect.value === "") {
+ daySelect.value = previousDay - 3;
+ }
+ }
+}
+
+function populateYears() {
+ // get this year as a number
+ var date = new Date();
+ var year = date.getFullYear();
+
+ // Make this year, and the 100 years before it available in the year &lt;select&gt;
+ for(var i = 0; i &lt;= 100; i++) {
+ var option = document.createElement('option');
+ option.textContent = year-i;
+ yearSelect.appendChild(option);
+ }
+}
+
+// when the month or year &lt;select&gt; values are changed, rerun populateDays()
+// in case the change affected the number of available days
+yearSelect.onchange = function() {
+ populateDays(monthSelect.value);
+}
+
+monthSelect.onchange = function() {
+ populateDays(monthSelect.value);
+}
+
+//preserve day selection
+var previousDay;
+
+// update what day has been set to previously
+// see end of populateDays() for usage
+daySelect.onchange = function() {
+ previousDay = daySelect.value;
+}</pre>
+
+<div class="note">
+<p><strong>Note</strong>: Remember that some years have 53 weeks in them (see <a href="https://en.wikipedia.org/wiki/ISO_week_date#Weeks_per_year">Weeks per year</a>)! You'll need to take this into consideration when developing production apps.</p>
+</div>
+
+<h2 id="Специфікації">Специфікації</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comments</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('HTML WHATWG', 'forms.html#date-state-(type=date)', '&lt;input type="date"&gt;')}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML5 W3C', 'forms.html#date-state-(type=date)', '&lt;input type="date"&gt;')}}</td>
+ <td>{{Spec2('HTML5 W3C')}}</td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Сумісність_з_оглядачами">Сумісність з оглядачами</h2>
+
+
+
+<p>{{Compat("html.elements.input.input-date")}}</p>
+
+<h2 id="Дивіться_також">Дивіться також</h2>
+
+<ul>
+ <li>The generic {{HTMLElement("input")}} element and the interface used to manipulate it, {{domxref("HTMLInputElement")}}</li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/The_native_form_widgets#Date_and_time_picker">Date and Time picker tutorial</a></li>
+ <li><a href="/en-US/docs/Web/HTML/Date_and_time_formats">Date and time formats used in HTML</a></li>
+</ul>
diff --git a/files/uk/web/html/element/input/datetime-local/index.html b/files/uk/web/html/element/input/datetime-local/index.html
new file mode 100644
index 0000000000..b8e88ea62e
--- /dev/null
+++ b/files/uk/web/html/element/input/datetime-local/index.html
@@ -0,0 +1,543 @@
+---
+title: <input type="datetime-local">
+slug: Web/HTML/Element/input/datetime-local
+translation_of: Web/HTML/Element/input/datetime-local
+---
+<div>{{HTMLRef}}</div>
+
+<p><span class="seoSummary">{{htmlelement("input")}} типу <strong><code>datetime-local</code></strong> створює елемент керування, який дозволяє користувачу легко вводити і дату, і час, включаючи рік, місяць, день і час у годинах і хвилинах. Застосовується часовий пояс користувача.</span> Вигляд елемента змінюється в загальному залежно від браузера; на даний час його підтримка є непостійною, для настільних пристроїв тільки Chrome/Opera й Edge, а для мобільних тільки найновіші браузери мають дієві його розробки. В інших браузерах вони занепали до простих елементів типу <code><a href="/en-US/docs/Web/HTML/Element/input/text">&lt;input type="text"&gt;</a></code>.</p>
+
+<p>Про підтримку секунд нема й мови.</p>
+
+<div>{{EmbedInteractiveExample("pages/tabbed/input-datetime-local.html", "tabbed-standard")}}</div>
+
+<p class="hidden">Джерело цього інтерактивного прикладу зберегається в репозиторії GitHub. Якщо хочете зробити внесок у проект інтерактивних прикладів, будь ласка, зробіть клон <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples </a>і відправте нам pull request.</p>
+
+<div class="note">
+<p><strong>Примітка:</strong> Через обмежену підтримку браузерами формату <code>datetime-local</code>, і відмінності в роботі елементів введення "input", на даний час, можливо, краще було би вживати якийсь фреймворк чи бібліотеку для їх відображення або використовувати ваш власний елемент введення. Іншим підходом може бути вживання окремих елементів <code>date</code> і <code>time</code>, кожен з яких підтримується ширше, ніж <code>datetime-local</code>.</p>
+</div>
+
+<p>Також деякі браузери для введення часу можуть вдаватися тільки до елемента текстового типу, що перевіряє, чи введені символи становлять правильні значення дати/часу перед відправленням їх на сервер, але небажано покладатися на цей підхід, оскільки його поведінку важко передбачити.</p>
+
+<p>Для тих із вас, хто не користується браузером із підтримкою <code>datetime-local</code>, елементи керування у Chrome/Opera виглядатимуть як на наступному знімку. Клацнувши справа значок стрілочки вниз, ви отримаєте вибирач дати, а час маєте ввести вручну.</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/14949/datetime-local-chrome.png" style="display: block; height: 224px; margin: 0px auto; width: 280px;"></p>
+
+<p>The Edge <code>datetime-local</code> control looks like the below; clicking the date and the time parts of the value bring up two separate pickers for you, so you can easily set both the date and the time. This is somewhat like having <code>date</code> and <code>time</code> widgets both created for you and merged into one.</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/14953/datetime-local-picker-edge1.png" style="display: block; height: 398px; margin: 0px auto; width: 320px;"></p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/14955/datetime-local-picker-edge2.png" style="display: block; height: 394px; margin: 0px auto; width: 264px;"></p>
+
+<table class="properties">
+ <tbody>
+ <tr>
+ <td><strong>{{anch("Value")}}</strong></td>
+ <td>A {{domxref("DOMString")}} representing a date and time (in the local time zone), or empty.</td>
+ </tr>
+ <tr>
+ <td><strong>Events</strong></td>
+ <td>{{event("change")}} and {{event("input")}}.</td>
+ </tr>
+ <tr>
+ <td><strong>Supported Common Attributes</strong></td>
+ <td>{{htmlattrxref("autocomplete", "input")}}, {{htmlattrxref("list", "input")}}, {{htmlattrxref("readonly", "input")}}, and {{htmlattrxref("step", "input")}}.</td>
+ </tr>
+ <tr>
+ <td><strong>IDL attributes</strong></td>
+ <td><code>list</code>, <code>value</code>, <code>valueAsNumber</code>.</td>
+ </tr>
+ <tr>
+ <td><strong>Methods</strong></td>
+ <td>{{domxref("HTMLInputElement.select", "select()")}}, {{domxref("HTMLInputElement.stepDown", "stepDown()")}}, {{domxref("HTMLInputElement.stepUp", "stepUp()")}}.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Value">Value</h2>
+
+<p>A {{domxref("DOMString")}} representing the value of the date entered into the input. You can set a default value for the input by including a date and time inside the {{htmlattrxref("value", "input")}} attribute, like so:</p>
+
+<pre class="brush: html">&lt;label for="party"&gt;Enter a date and time for your party booking:&lt;/label&gt;
+&lt;input id="party" type="datetime-local" name="partydate" value="2017-06-01T08:30"&gt;</pre>
+
+<p>{{ EmbedLiveSample('Value', 600, 60) }}</p>
+
+<p>One thing to note is that the displayed date and time formats differ from the actual <code>value</code>; the displayed date and time are formatted according to the user's locale as reported by their operating system, whereas the date/time <code>value</code> is always formatted <code>yyyy-MM-ddThh:mm</code>. When the above value submitted to the server, for example, it will look like <code>"partydate=2017-06-01T08:30"</code>.</p>
+
+<div class="note">
+<p><strong>Note:</strong> Also bear in mind that if such data is submitted via HTTP <code><a href="/en-US/docs/Web/HTTP/Methods/GET">GET</a></code>, the colon character will need to be escaped for inclusion in the URL parameters, e.g. <code>partydate=2017-06-01T08%3A30</code>. See {{jsxref("Global_Objects/encodeURI", "encodeURI()")}} for one way to do this.</p>
+</div>
+
+<p>You can also get and set the date value in JavaScript using the {{domxref("HTMLInputElement.value")}} property, for example:</p>
+
+<pre class="brush: js">var dateControl = document.querySelector('input[type="datetime-local"]');
+dateControl.value = '2017-06-01T08:30';</pre>
+
+<p>There are several methods provided by JavaScript's {{jsxref("Date")}} that can be used to convert numeric date information into a properly-formatted string, or you can do it manually. For example, the {{jsxref("Date.toISOString()")}} method can be used for this purpose.</p>
+
+<h2 id="Using_datetime-local_inputs">Using datetime-local inputs</h2>
+
+<p>Date/time inputs sound convenient at first glance; they provide an easy UI for choosing dates and times, and they normalize the data format sent to the server, regardless of the user's locale. However, there are issues with <code>&lt;input type="datetime-local"&gt;</code> because of the limited browser support.</p>
+
+<p>We'll look at basic and more complex uses of <code>&lt;input type="datetime-local"&gt;</code>, then offer advice on mitigating the browser support issue later on (see {{anch("Handling browser support")}}).</p>
+
+<h3 id="Basic_uses_of_datetime-local">Basic uses of datetime-local</h3>
+
+<p>The simplest use of <code>&lt;input type="datetime-local"&gt;</code> involves a basic <code>&lt;input&gt;</code> and {{htmlelement("label")}} element combination, as seen below:</p>
+
+<pre class="brush: html">&lt;form&gt;
+    &lt;label for="party"&gt;Enter a date and time for your party booking:&lt;/label&gt;
+    &lt;input id="party" type="datetime-local" name="partydate"&gt;
+&lt;/form&gt;</pre>
+
+<p>{{ EmbedLiveSample('Basic_uses_of_datetime-local', 600, 40) }}</p>
+
+<h3 id="Setting_maximum_and_minimum_dates_and_times">Setting maximum and minimum dates and times</h3>
+
+<p>You can use the {{htmlattrxref("min", "input")}} and {{htmlattrxref("max", "input")}} attributes to restrict the dates/times that can be chosen by the user. In the following example we are setting a minimum datetime of <code>2017-06-01T08:30</code> and a maximum datetime of <code>2017-06-30T16:30</code>:</p>
+
+<pre class="brush: html">  &lt;form&gt;
+    &lt;label for="party"&gt;Enter a date and time for your party booking:&lt;/label&gt;
+    &lt;input id="party" type="datetime-local" name="partydate" min="2017-06-01T08:30" max="2017-06-30T16:30"&gt;
+  &lt;/form&gt;</pre>
+
+<p>{{ EmbedLiveSample('Setting_maximum_and_minimum_dates_and_times', 600, 40) }}</p>
+
+<p>The result here is that:</p>
+
+<ul>
+ <li>Only days in June 2017 can be selected — only the "days" part of the date value will be editable, and dates outside June can't be scrolled to in the datepicker widget.</li>
+ <li>Depending on what browser you are using, you might find that times outside the specified values might not be selectable in the time picker (e.g. Edge), or invalid (see {{anch("Validation")}}) but still available (e.g. Chrome).</li>
+</ul>
+
+<div class="note">
+<p><strong>Note</strong>: You should be able to use the {{htmlattrxref("step", "input")}} attribute to vary the number of days jumped each time the date is incremented (e.g. maybe you only want to make Saturdays selectable). However, this does not seem to work effectively in any implementation at the time of writing.</p>
+</div>
+
+<h3 id="Controlling_input_size">Controlling input size</h3>
+
+<p><code>&lt;input type="datetime-local"&gt;</code> doesn't support form control sizing attributes such as {{htmlattrxref("size", "input")}}. You'll have to resort to <a href="/en-US/docs/Web/CSS">CSS</a> for customizing the sizes of these elements.</p>
+
+<h3 id="Setting_timezones">Setting timezones</h3>
+
+<p>One thing the <code>datetime-local</code> input type doesn't provide is a way to set the time zone and/or locale of the date/time control. This was available in the <code><a href="/en-US/docs/Web/HTML/Element/input/datetime">datetime</a></code> input type, but this type is now obsolete, having been removed from the spec. The main reasons why this was removed are a lack of implementation in browsers, and concerns over the user interface/experience. It is easier to just have a control (or controls) for setting the date/time and then deal with the locale in a separate control.</p>
+
+<p>For example, if you are creating a system where the user is likely to already be logged in, with their locale already set, you could provide the timezone in a <code><a href="/en-US/docs/Web/HTML/Element/input/hidden">hidden</a></code> input type. For example:</p>
+
+<pre class="brush: html">&lt;input type="hidden" id="timezone" name="timezone" value="-08:00"&gt;</pre>
+
+<p>On the other hand, if you were required to allow the user to enter a timezone along with a date/time input, you could provide a means of inputting a timezone, such as a {{htmlelement("select")}} element:</p>
+
+<pre class="brush: html">&lt;select name="timezone_offset" id="timezone-offset" class="span5"&gt;
+ &lt;option value="-12:00"&gt;(GMT -12:00) Eniwetok, Kwajalein&lt;/option&gt;
+ &lt;option value="-11:00"&gt;(GMT -11:00) Midway Island, Samoa&lt;/option&gt;
+ &lt;option value="-10:00"&gt;(GMT -10:00) Hawaii&lt;/option&gt;
+ &lt;option value="-09:50"&gt;(GMT -9:30) Taiohae&lt;/option&gt;
+ &lt;option value="-09:00"&gt;(GMT -9:00) Alaska&lt;/option&gt;
+ &lt;option value="-08:00"&gt;(GMT -8:00) Pacific Time (US &amp;amp; Canada)&lt;/option&gt;
+
+ ...
+
+&lt;/select&gt;</pre>
+
+<p>In either case, the date/time and time zone values would be submitted to the server as separate data points, and then you'd need to store them appropriately in the database on the server-side.</p>
+
+<div class="note">
+<p><strong>Note</strong>: The above code snippet is taken from <a href="https://gist.github.com/nodesocket/3919205">All world timezones in an HTML select element</a>.</p>
+</div>
+
+<h2 id="Validation">Validation</h2>
+
+<p>By default, <code>&lt;input type="datetime-local"&gt;</code> does not apply any validation to entered values. The UI implementations generally don't let you enter anything that isn't a date/time — which is helpful — but a user might still fill in no value and submit, or enter an invalid date and/or time (e.g. the 32nd of April).</p>
+
+<p>You can use {{htmlattrxref("min", "input")}} and {{htmlattrxref("max", "input")}} to restrict the available dates (see anch("Setting maximum and minimum dates")), and you can use the {{htmlattrxref("required", "input")}} attribute to make filling in the date/time mandatory. As a result, supporting browsers will display an error if you try to submit a date that is outside the set bounds, or an empty date field.</p>
+
+<p>Let's look at an example; here we've set minimum and maximum date/time values, and also made the field required:</p>
+
+<pre class="brush: html">&lt;form&gt;
+    &lt;div&gt;
+        &lt;label for="party"&gt;Choose your preferred party date and time (required, June 1st 8.30am to June 30th 4.30pm):&lt;/label&gt;
+        &lt;input id="party" type="datetime-local" name="partydate" min="2017-06-01T08:30" max="2017-06-30T16:30" required&gt;
+        &lt;span class="validity"&gt;&lt;/span&gt;
+    &lt;/div&gt;
+    &lt;div&gt;
+        &lt;input type="submit" value="Book party!"&gt;
+    &lt;/div&gt;
+&lt;/form&gt;</pre>
+
+<p>If you try to submit the form with an incomplete date (or with a date outside the set bounds), the browser displays an error. Try playing with the example now:</p>
+
+<p>{{ EmbedLiveSample('Validation', 600, 120) }}</p>
+
+<p>Here's a screenshot for those of you who aren't using a supporting browser:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/14957/datetime-local-error.png" style="display: block; height: 100px; margin: 0px auto; width: 558px;"></p>
+
+<p>Here's the CSS used in the above example. Here we make use of the {{cssxref(":valid")}} and {{cssxref(":invalid")}} CSS properties to style the input based on whether or not the current value is valid. We had to put the icons on a {{htmlelement("span")}} next to the input, not on the input itself, because in Chrome the generated content is placed inside the form control, and can't be styled or shown effectively.</p>
+
+<pre class="brush: css">div {
+ margin-bottom: 10px;
+ display: flex;
+ align-items: center;
+}
+
+label {
+ display: inline-block;
+ width: 300px;
+}
+
+input:invalid+span:after {
+ content: '✖';
+ padding-left: 5px;
+}
+
+input:valid+span:after {
+ content: '✓';
+ padding-left: 5px;
+}</pre>
+
+<div class="warning">
+<p><strong>Important</strong>: HTML form validation is <em>not</em> a substitute for scripts that ensure that the entered data is in the proper format.  It's far too easy for someone to make adjustments to the HTML that allow them to bypass the validation, or to remove it entirely. It's also possible for someone to simply bypass your HTML entirely and submit the data directly to your server. If your server-side code fails to validate the data it receives, disaster could strike when improperly-formatted data is submitted (or data which is too large, is of the wrong type, and so forth).</p>
+</div>
+
+<h2 id="Handling_browser_support">Handling browser support</h2>
+
+<p>As mentioned above, the major problem with using date inputs at the time of writing is browser support — only Chrome/Opera and Edge support it on desktop, and most modern browsers on mobile. As an example, the <code>datetime-local</code> picker on Firefox for Android looks like this:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/14951/datetime-local-fxa.png" style="display: block; height: 640px; margin: 0px auto; width: 360px;"></p>
+
+<p>Non-supporting browsers gracefully degrade to a text input, but this creates problems both in terms of consistency of user interface (the presented control will be different), and data handling.</p>
+
+<p>The second problem is the most serious; as we mentioned earlier, with a <code>datetime-local</code> input, the actual value is always normalized to the format <code>yyyy-mm-ddThh:mm</code>. With a text input on the other hand, by default the browser has no recognition of what format the date should be in, and there are lots of different ways in which people write dates and times, for example:</p>
+
+<ul>
+ <li><code>ddmmyyyy</code></li>
+ <li><code>dd/mm/yyyy</code></li>
+ <li><code>mm/dd/yyyy</code></li>
+ <li><code>dd-mm-yyyy</code></li>
+ <li><code>mm-dd-yyyy</code></li>
+ <li><code>mm-dd-yyyy hh:mm</code> (12 hour clock)</li>
+ <li><code>mm-dd-yyyy hh:mm</code> (24 hour clock)</li>
+ <li>etc.</li>
+</ul>
+
+<p>One way around this is to put a {{htmlattrxref("pattern", "input")}} attribute on your <code>datetime-local</code> input. Even though the <code>datetime-local</code> input doesn't use it, the text input fallback will. For example, try viewing the following demo in a non-supporting browser:</p>
+
+<pre class="brush: html">&lt;form&gt;
+  &lt;div&gt;
+    &lt;label for="party"&gt;Choose your preferred party date and time (required, June 1st 8.30am to June 30th 4.30pm):&lt;/label&gt;
+   &lt;input id="party" type="datetime-local" name="partydate"
+           min="2017-06-01T08:30" max="2017-06-30T16:30"
+           pattern="[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}" required&gt;
+    &lt;span class="validity"&gt;&lt;/span&gt;
+  &lt;/div&gt;
+  &lt;div&gt;
+    &lt;input type="submit" value="Book party!"&gt;
+  &lt;/div&gt;
+  &lt;input type="hidden" id="timezone" name="timezone" value="-08:00"&gt;
+&lt;/form&gt;</pre>
+
+<p>{{ EmbedLiveSample('Handling_browser_support', 600, 100) }}</p>
+
+<p>If you try submitting it, you'll see that the browser now displays an error message (and highlights the input as invalid) if your entry doesn't match the pattern <code>nnnn-nn-nnTnn:nn</code>, where <code>n</code> is a number from 0 to 9. Of course, this doesn't stop people from entering invalid dates, or incorrectly formatted dates and times.</p>
+
+<p>And what user is going to understand the pattern they need to enter the time and date in?</p>
+
+<p>We still have a problem.</p>
+
+<div class="hidden">
+<pre class="brush: css">div {
+ margin-bottom: 10px;
+}
+
+input:invalid + span {
+ position: relative;
+}
+
+input:invalid + span:after {
+ content: '✖';
+ position: absolute;
+ right: -18px;
+}
+
+input:valid + span {
+ position: relative;
+}
+
+input:valid + span:after {
+ content: '✓';
+ position: absolute;
+ right: -18px;
+}</pre>
+</div>
+
+<p>The best way to deal with dates in forms in a cross-browser way at the moment is to get the user to enter the day, month, year, and time in separate controls ({{htmlelement("select")}} elements being popular — see below for an implementation), or use JavaScript libraries such as <a href="https://jqueryui.com/datepicker/">jQuery date picker</a>, and the <a href="http://timepicker.co/">jQuery timepicker plugin</a>.</p>
+
+<h2 id="Examples">Examples</h2>
+
+<p>In this example we create two sets of UI elements for choosing datetimes — a native <code>&lt;input type="datetime-local"&gt;</code> picker, and a set of five {{htmlelement("select")}} elements for choosing dates and times in older browsers that don't support the native input.</p>
+
+<p>{{ EmbedLiveSample('Examples', 600, 140) }}</p>
+
+<p>The HTML looks like so:</p>
+
+<pre class="brush: html">&lt;form&gt;
+  &lt;div class="nativeDateTimePicker"&gt;
+    &lt;label for="party"&gt;Choose a date and time for your party:&lt;/label&gt;
+    &lt;input type="datetime-local" id="party" name="bday"&gt;
+    &lt;span class="validity"&gt;&lt;/span&gt;
+  &lt;/div&gt;
+  &lt;p class="fallbackLabel"&gt;Choose a date and time for your party:&lt;/p&gt;
+  &lt;div class="fallbackDateTimePicker"&gt;
+    &lt;div&gt;
+      &lt;span&gt;
+        &lt;label for="day"&gt;Day:&lt;/label&gt;
+        &lt;select id="day" name="day"&gt;
+        &lt;/select&gt;
+      &lt;/span&gt;
+      &lt;span&gt;
+        &lt;label for="month"&gt;Month:&lt;/label&gt;
+        &lt;select id="month" name="month"&gt;
+          &lt;option selected&gt;January&lt;/option&gt;
+          &lt;option&gt;February&lt;/option&gt;
+          &lt;option&gt;March&lt;/option&gt;
+          &lt;option&gt;April&lt;/option&gt;
+          &lt;option&gt;May&lt;/option&gt;
+          &lt;option&gt;June&lt;/option&gt;
+          &lt;option&gt;July&lt;/option&gt;
+          &lt;option&gt;August&lt;/option&gt;
+          &lt;option&gt;September&lt;/option&gt;
+          &lt;option&gt;October&lt;/option&gt;
+          &lt;option&gt;November&lt;/option&gt;
+          &lt;option&gt;December&lt;/option&gt;
+        &lt;/select&gt;
+      &lt;/span&gt;
+      &lt;span&gt;
+        &lt;label for="year"&gt;Year:&lt;/label&gt;
+        &lt;select id="year" name="year"&gt;
+        &lt;/select&gt;
+      &lt;/span&gt;
+    &lt;/div&gt;
+    &lt;div&gt;
+      &lt;span&gt;
+        &lt;label for="hour"&gt;Hour:&lt;/label&gt;
+        &lt;select id="hour" name="hour"&gt;
+        &lt;/select&gt;
+      &lt;/span&gt;
+      &lt;span&gt;
+        &lt;label for="minute"&gt;Minute:&lt;/label&gt;
+        &lt;select id="minute" name="minute"&gt;
+        &lt;/select&gt;
+      &lt;/span&gt;
+    &lt;/div&gt;
+  &lt;/div&gt;
+&lt;/form&gt;</pre>
+
+<p>The months are hard-coded (as they are always the same), while the day and year values are dynamically generated depending on the currently selected month and year, and the current year respectively (see the code comments below for detailed explanations of how these functions work.) We also decided to dynamically generate the hours and minutes, as there are so many of them!</p>
+
+<div class="hidden">
+<pre class="brush: css">div {
+ margin-bottom: 10px;
+ position: relative;
+}
+
+input[type="number"] {
+ width: 100px;
+}
+
+input + span {
+ padding-right: 30px;
+}
+
+input:invalid+span:after {
+ position: absolute;
+ content: '✖';
+ padding-left: 5px;
+}
+
+input:valid+span:after {
+ position: absolute;
+ content: '✓';
+ padding-left: 5px;
+}</pre>
+</div>
+
+<p>The other part of the code that may be of interest is the feature detection code — to detect whether the browser supports <code>&lt;input type="datetime-local"&gt;</code>, we create a new {{htmlelement("input")}} element, set its <code>type</code> to <code>datetime-local</code>, then immediately check what its type is set to. Browsers that don't support <code>datetime-local</code> return <code>text</code>, since that's what <code>datetime-local</code> falls back to. If <code>&lt;input type="datetime-local"&gt;</code> is not supported, we hide the native picker and show the fallback picker UI ({{htmlelement("select")}}) instead.</p>
+
+<pre class="brush: js">// define variables
+var nativePicker = document.querySelector('.nativeDateTimePicker');
+var fallbackPicker = document.querySelector('.fallbackDateTimePicker');
+var fallbackLabel = document.querySelector('.fallbackLabel');
+
+var yearSelect = document.querySelector('#year');
+var monthSelect = document.querySelector('#month');
+var daySelect = document.querySelector('#day');
+var hourSelect = document.querySelector('#hour');
+var minuteSelect = document.querySelector('#minute');
+
+// hide fallback initially
+fallbackPicker.style.display = 'none';
+fallbackLabel.style.display = 'none';
+
+// test whether a new datetime-local input falls back to a text input or not
+var test = document.createElement('input');
+test.type = 'datetime-local';
+// if it does, run the code inside the if() {} block
+if(test.type === 'text') {
+ // hide the native picker and show the fallback
+ nativePicker.style.display = 'none';
+ fallbackPicker.style.display = 'block';
+ fallbackLabel.style.display = 'block';
+
+ // populate the days and years dynamically
+ // (the months are always the same, therefore hardcoded)
+ populateDays(monthSelect.value);
+ populateYears();
+ populateHours();
+ populateMinutes();
+}
+
+function populateDays(month) {
+ // delete the current set of &lt;option&gt; elements out of the
+ // day &lt;select&gt;, ready for the next set to be injected
+ while(daySelect.firstChild){
+ daySelect.removeChild(daySelect.firstChild);
+ }
+
+ // Create variable to hold new number of days to inject
+ var dayNum;
+
+ // 31 or 30 days?
+ if(month === 'January' | month === 'March' | month === 'May' | month === 'July' | month === 'August' | month === 'October' | month === 'December') {
+ dayNum = 31;
+ } else if(month === 'April' | month === 'June' | month === 'September' | month === 'November') {
+ dayNum = 30;
+ } else {
+ // If month is February, calculate whether it is a leap year or not
+ var year = yearSelect.value;
+ (year - 2016) % 4 === 0 ? dayNum = 29 : dayNum = 28;
+ }
+
+ // inject the right number of new &lt;option&gt; elements into the day &lt;select&gt;
+ for(i = 1; i &lt;= dayNum; i++) {
+ var option = document.createElement('option');
+ option.textContent = i;
+ daySelect.appendChild(option);
+ }
+
+ // if previous day has already been set, set daySelect's value
+ // to that day, to avoid the day jumping back to 1 when you
+ // change the year
+ if(previousDay) {
+ daySelect.value = previousDay;
+
+ // If the previous day was set to a high number, say 31, and then
+ // you chose a month with less total days in it (e.g. February),
+ // this part of the code ensures that the highest day available
+ // is selected, rather than showing a blank daySelect
+ if(daySelect.value === "") {
+ daySelect.value = previousDay - 1;
+ }
+
+ if(daySelect.value === "") {
+ daySelect.value = previousDay - 2;
+ }
+
+ if(daySelect.value === "") {
+ daySelect.value = previousDay - 3;
+ }
+ }
+}
+
+function populateYears() {
+ // get this year as a number
+ var date = new Date();
+ var year = date.getFullYear();
+
+ // Make this year, and the 100 years before it available in the year &lt;select&gt;
+ for(var i = 0; i &lt;= 100; i++) {
+ var option = document.createElement('option');
+ option.textContent = year-i;
+ yearSelect.appendChild(option);
+ }
+}
+
+function populateHours() {
+ // populate the hours &lt;select&gt; with the 24 hours of the day
+ for(var i = 0; i &lt;= 23; i++) {
+ var option = document.createElement('option');
+ option.textContent = (i &lt; 10) ? ("0" + i) : i;
+ hourSelect.appendChild(option);
+ }
+}
+
+function populateMinutes() {
+ // populate the minutes &lt;select&gt; with the 60 hours of each minute
+ for(var i = 0; i &lt;= 59; i++) {
+ var option = document.createElement('option');
+ option.textContent = (i &lt; 10) ? ("0" + i) : i;
+ minuteSelect.appendChild(option);
+ }
+}
+
+// when the month or year &lt;select&gt; values are changed, rerun populateDays()
+// in case the change affected the number of available days
+yearSelect.onchange = function() {
+ populateDays(monthSelect.value);
+}
+
+monthSelect.onchange = function() {
+ populateDays(monthSelect.value);
+}
+
+//preserve day selection
+var previousDay;
+
+// update what day has been set to previously
+// see end of populateDays() for usage
+daySelect.onchange = function() {
+ previousDay = daySelect.value;
+}</pre>
+
+<div class="note">
+<p><strong>Note</strong>: Remember that some years have 53 weeks in them (see <a href="https://en.wikipedia.org/wiki/ISO_week_date#Weeks_per_year">Weeks per year</a>)! You'll need to take this into consideration when developing production apps.</p>
+</div>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comments</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('HTML WHATWG', 'forms.html#local-date-and-time-state-(type=datetime-local)', '&lt;input type="datetime-local"&gt;')}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML5 W3C', 'forms.html##local-date-and-time-state-(type=datetime-local)', '&lt;input type="datetime-local"&gt;')}}</td>
+ <td>{{Spec2('HTML5 W3C')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+
+
+<p>{{Compat("html.elements.input.input-datetime-local")}}</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li>The generic {{HTMLElement("input")}} element and the interface used to manipulate it, {{domxref("HTMLInputElement")}}</li>
+ <li><code><a href="/en-US/docs/Web/HTML/Element/input/date">&lt;input type="date"&gt;</a></code> and <code><a href="/en-US/docs/Web/HTML/Element/input/time">&lt;input type="time"&gt;</a></code></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/The_native_form_widgets#Date_and_time_picker">Date and Time picker tutorial</a></li>
+</ul>
diff --git a/files/uk/web/html/element/input/index.html b/files/uk/web/html/element/input/index.html
new file mode 100644
index 0000000000..3c0f2289b3
--- /dev/null
+++ b/files/uk/web/html/element/input/index.html
@@ -0,0 +1,753 @@
+---
+title: '<input>: The Input (Form Input) element'
+slug: Web/HTML/Element/input
+tags:
+ - Data entry
+ - Element
+ - Forms
+ - HTML
+ - HTML forms
+ - HTML input tag
+ - Input
+ - MakeBrowserAgnostic
+ - NeedsBrowserCompatibility
+ - NeedsMobileBrowserCompatibility
+ - NeedsTranslation
+ - Reference
+ - TopicStub
+ - Web
+translation_of: Web/HTML/Element/input
+---
+<div>{{HTMLRef}}</div>
+
+<p><span class="seoSummary">The <strong>HTML <code>&lt;input&gt;</code> element</strong> is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and {{Glossary("user agent")}}.</span></p>
+
+<div>{{EmbedInteractiveExample("pages/tabbed/input-input.html", "tabbed-standard")}}</div>
+
+<p class="hidden">The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a href="https://github.com/mdn/interactive-examples
+&lt;https://github.com/mdn/interactive-examples>">https://github.com/mdn/interactive-examples </a> and send us a pull request.</p>
+
+<table class="properties">
+ <tbody>
+ <tr>
+ <th scope="row"><a href="/en-US/docs/HTML/Content_categories">Content categories</a></th>
+ <td><a href="/en-US/docs/HTML/Content_categories#Flow_content">Flow content</a>, listed, submittable, resettable, form-associated element, <a href="/en-US/docs/HTML/Content_categories#Phrasing_content">phrasing content</a>. If the {{htmlattrxref("type", "input")}} is not <code>hidden</code>, then labelable element, palpable content.</td>
+ </tr>
+ <tr>
+ <th scope="row">Permitted content</th>
+ <td>None, it is an {{Glossary("empty element")}}.</td>
+ </tr>
+ <tr>
+ <th scope="row">Tag omission</th>
+ <td>Must have a start tag and must not have an end tag.</td>
+ </tr>
+ <tr>
+ <th scope="row">Permitted parents</th>
+ <td>Any element that accepts <a href="/en-US/docs/HTML/Content_categories#Phrasing_content">phrasing content</a>.</td>
+ </tr>
+ <tr>
+ <th scope="row">Permitted ARIA roles</th>
+ <td>
+ <ul>
+ <li><code>type=button</code>: {{ARIARole("link")}}, {{ARIARole("menuitem")}}, {{ARIARole("menuitemcheckbox")}}, {{ARIARole("menuitemradio")}}, {{ARIARole("radio")}}, {{ARIARole("switch")}}, {{ARIARole("tab")}}</li>
+ <li><code>type=checkbox</code>: {{ARIARole("button")}}, {{ARIARole("menuitemcheckbox")}}, {{ARIARole("option")}}, {{ARIARole("switch")}}</li>
+ <li><code>type=image</code>: {{ARIARole("link")}}, {{ARIARole("menuitem")}}, {{ARIARole("menuitemcheckbox")}}, {{ARIARole("menuitemradio")}}, {{ARIARole("radio")}}, {{ARIARole("switch")}}</li>
+ <li><code>type=radio</code>: {{ARIARole("menuitemradio")}}</li>
+ <li><code>type=color|date|datetime|datetime-local|email|file</code>: None</li>
+ <li><code>type=hidden|month|number|password|range|reset</code>: None</li>
+ <li><code>type=search|submit|tel|text|url|week</code>: None</li>
+ </ul>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row">DOM interface</th>
+ <td>{{domxref("HTMLInputElement")}}</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Form_&lt;input>_types">Form <code>&lt;input&gt;</code> types</h2>
+
+<p>How an <code>&lt;input&gt;</code> works varies considerably depending on the value of its <code>type</code> attribute, hence the different types are covered in their own separate reference pages. If this attributes is not specified, the default type adopted is <code>text</code>.</p>
+
+<p>The available types are as follows:</p>
+
+<ul>
+ <li><code>{{HTMLElement("input/button", "button")}}</code>: A push button with no default behavior.</li>
+ <li><code>{{HTMLElement("input/checkbox", "checkbox")}}</code>: A check box allowing single values to be selected/deselected.</li>
+ <li><code>{{HTMLElement("input/color", "color")}}</code>: {{HTMLVersionInline("5")}} A control for specifying a color. A color picker's UI has no required features other than accepting simple colors as text (<a href="https://www.w3.org/TR/html5/forms.html#color-state-(type=color)">more info</a>).</li>
+ <li><code>{{HTMLElement("input/date", "date")}}</code>: {{HTMLVersionInline("5")}} A control for entering a date (year, month, and day, with no time).</li>
+ <li><code>{{HTMLElement("input/datetime-local", "datetime-local")}}</code>: {{HTMLVersionInline("5")}} A control for entering a date and time, with no time zone.</li>
+ <li><code>{{HTMLElement("input/email", "email")}}</code>: {{HTMLVersionInline("5")}} A field for editing an e-mail address.</li>
+ <li><code>{{HTMLElement("input/file", "file")}}</code>: A control that lets the user select a file. Use the <strong>accept</strong> attribute to define the types of files that the control can select.</li>
+ <li><code>{{HTMLElement("input/hidden", "hidden")}}</code>: A control that is not displayed but whose value is submitted to the server.</li>
+ <li><code>{{HTMLElement("input/image", "image")}}</code>: A graphical submit button. You must use the <strong>src</strong> attribute to define the source of the image and the <strong>alt</strong> attribute to define alternative text. You can use the <strong>height</strong> and <strong>width</strong> attributes to define the size of the image in pixels.</li>
+ <li><code>{{HTMLElement("input/month", "month")}}</code>: {{HTMLVersionInline("5")}} A control for entering a month and year, with no time zone.</li>
+ <li><code>{{HTMLElement("input/number", "number")}}</code>: {{HTMLVersionInline("5")}} A control for entering a number.</li>
+ <li><code>{{HTMLElement("input/password", "password")}}</code>: A single-line text field whose value is obscured. Use the <strong>maxlength</strong> and <strong>minlength</strong> attributes to specify the maximum length of the value that can be entered.
+ <div class="note"><strong>Note</strong>: Any forms involving sensitive information like passwords (e.g. login forms) should be served over HTTPS; Firefox now implements multiple mechanisms to warn against insecure login forms — see <a href="/en-US/docs/Web/Security/Insecure_passwords">Insecure passwords</a>. Other browsers are also implementing similar mechanisms.</div>
+ </li>
+ <li><code>{{HTMLElement("input/radio", "radio")}}</code>: A radio button, allowing a single value to be selected out of multiple choices.</li>
+ <li><code>{{HTMLElement("input/range", "range")}}</code>: {{HTMLVersionInline("5")}} A control for entering a number whose exact value is not important.</li>
+ <li><code>{{HTMLElement("input/reset", "reset")}}</code>: A button that resets the contents of the form to default values.</li>
+ <li><code>{{HTMLElement("input/search", "search")}}</code>: {{HTMLVersionInline("5")}} A single-line text field for entering search strings. Line-breaks are automatically removed from the input value.</li>
+ <li><code>{{HTMLElement("input/submit", "submit")}}</code>: A button that submits the form.</li>
+ <li><code>{{HTMLElement("input/tel", "tel")}}</code>: {{HTMLVersionInline("5")}} A control for entering a telephone number.</li>
+ <li><code>{{HTMLElement("input/text", "text")}}</code>: A single-line text field. Line-breaks are automatically removed from the input value.</li>
+ <li><code>{{HTMLElement("input/time", "time")}}</code>: {{HTMLVersionInline("5")}} A control for entering a time value with no time zone.</li>
+ <li><code>{{HTMLElement("input/url", "url")}}</code>: {{HTMLVersionInline("5")}} A field for entering a URL.</li>
+ <li><code>{{HTMLElement("input/week", "week")}}</code>: {{HTMLVersionInline("5")}} A control for entering a date consisting of a week-year number and a week number with no time zone.</li>
+</ul>
+
+<p>Some input types are now obsolete:</p>
+
+<ul>
+ <li><code>{{HTMLElement("input/datetime", "datetime")}}</code>: {{HTMLVersionInline("5")}} {{deprecated_inline}} {{obsolete_inline}} A control for entering a date and time (hour, minute, second, and fraction of a second) based on UTC time zone. <strong>This feature has been <a href="https://github.com/whatwg/html/issues/336">removed from WHATWG HTML.</a></strong></li>
+</ul>
+
+<h2 id="Attributes">Attributes</h2>
+
+<h3 id="Global_&lt;input>_attributes">Global <code>&lt;input&gt;</code> attributes</h3>
+
+<p>This section lists the attributes available to all form <code>&lt;input&gt;</code> types. Non-global attributes — and global attributes that behave differently when specified on different <code>&lt;input&gt;</code> types — are listed on those types' individual pages.</p>
+
+<div class="note">
+<p><strong>Note</strong>: This includes the <a href="/en-US/docs/Web/HTML/Global_attributes">global HTML attributes</a>.</p>
+</div>
+
+<dl>
+ <dt>{{htmlattrdef("type")}}</dt>
+ <dd>The type of control to render. See {{anch("Form &lt;input&gt; types")}} for the individual types, with links to more information about each.</dd>
+ <dt>{{htmlattrdef("accept")}}</dt>
+ <dd>If the value of the <strong>type</strong> attribute is <code>file</code>, this attribute indicates the types of files that the server accepts — otherwise it's ignored. The value must be comma-separated unique “content type specifiers”:
+ <ul>
+ <li>A case-insensitive file extension starting with the STOP character (U+002E). (e.g. .jpg, .png, .doc).</li>
+ <li>A valid MIME type with no extensions.</li>
+ <li><code>audio/*</code> representing sound files. {{HTMLVersionInline("5")}}</li>
+ <li><code>video/*</code> representing video files. {{HTMLVersionInline("5")}}</li>
+ <li><code>image/*</code> representing image files. {{HTMLVersionInline("5")}}</li>
+ </ul>
+ </dd>
+ <dt>{{htmlattrdef("accesskey")}} {{HTMLVersionInline(4)}} only, {{obsoleteGeneric("inline", "HTML5")}}</dt>
+ <dd>Sets a keyboard key that the user can press to <a href="/en-US/docs/Mozilla/Tech/XUL/Tutorial/Focus_and_Selection">focus</a> the control. This attribute is global in HTML5 — see <a href="/en-US/docs/Web/HTML/Global_attributes/accesskey">the <code>accesskey</code> page</a> for more info.</dd>
+ <dt>{{htmlattrdef("autocomplete")}} {{HTMLVersionInline("5")}}</dt>
+ <dd>This attribute indicates if the input can be automatically completed by the browser, usually by remembering previous values the user has entered. {{page("/en-US/docs/Web/HTML/Attributes/autocomplete", "Values")}}</dd>
+ <dd>See <a href="/en-US/docs/Web/HTML/Attributes/autocomplete">The HTML autocomplete attribute</a> for additional information.</dd>
+ <dt>{{htmlattrdef("autofocus")}} {{HTMLVersionInline("5")}}</dt>
+ <dd>This Boolean attribute specifies that the input should have focus when the page loads, unless the user overrides it (e.g. by typing in a different control). Only one element in a document can have the <strong>autofocus</strong> attribute. It cannot be applied if the <strong>type</strong> attribute is <code>hidden</code>, because hidden inputs cannot be focused. Note that the input may be focused before the <a href="/en-US/docs/Web/Events/DOMContentLoaded"><code>DOMContentLoaded</code> event fires.</a>
+ <div class="warning"><strong>Warning</strong>: Automatically focusing a form control can confuse visually-impaired people who using screen-reading technology. When <code>autofocus</code> is assigned, screen-readers "teleport" their user to the form control without warning them beforehand.</div>
+ </dd>
+ <dt>{{htmlattrdef("capture")}}</dt>
+ <dd>
+ <p>If the value of the <strong>type</strong> attribute is <code>file</code>, this Boolean attribute indicates that capture of media directly from the device's sensors using a <a href="https://www.w3.org/TR/html-media-capture/#dfn-media-capture-mechanism">media capture mechanism</a> is preferred, such as a webcam or microphone.</p>
+ </dd>
+ <dt>{{htmlattrdef("checked")}}</dt>
+ <dd>
+ <p>If the value of the <strong>type</strong> attribute is <code>radio</code> or <code>checkbox</code>, this Boolean attribute pre-checks the control before the user interacts with it.</p>
+
+ <p>Unlike other browsers, Firefox by default <a href="https://stackoverflow.com/questions/5985839/bug-with-firefox-disabled-attribute-of-input-not-resetting-when-refreshing">persists the dynamic checked state</a> of an <code>&lt;input&gt;</code> across page loads. Use the {{htmlattrxref("autocomplete","input")}} attribute to control this feature.</p>
+ </dd>
+ <dt>{{htmlattrdef("disabled")}}</dt>
+ <dd>
+ <p>This Boolean attribute prevents the user from interacting with the input. In particular, the <code>click</code> event <a class="external" href="https://html.spec.whatwg.org/multipage/forms.html#enabling-and-disabling-form-controls:-the-disabled-attribute">is not dispatched</a> on disabled controls, and disabled controls aren't submitted with their form.</p>
+
+ <p>Unlike other browsers, Firefox will by default <a href="https://stackoverflow.com/questions/5985839/bug-with-firefox-disabled-attribute-of-input-not-resetting-when-refreshing">persist the dynamic disabled state</a> of an <code>&lt;input&gt;</code> across page loads. Use the {{htmlattrxref("autocomplete","input")}} attribute to control this feature.</p>
+ </dd>
+ <dt>{{htmlattrdef("form")}} {{HTMLVersionInline("5")}}</dt>
+ <dd>The form element that the input element is associated with (its <em>form owner</em>). The value of the attribute must be an <strong>id</strong> of a {{HTMLElement("form")}} element in the same document. If this attribute isn't used, the <code>&lt;input&gt;</code> element is associated with its nearest ancestor {{HTMLElement("form")}} element, if any. This attribute lets you to place <code>&lt;input&gt;</code> elements anywhere within a document, not just as descendants of form elements. An input can be associated with at most one form.</dd>
+ <dt>{{htmlattrdef("formaction")}} {{HTMLVersionInline("5")}}</dt>
+ <dd>The URL that processes the data submitted by the input element, if it is a submit button or image. This attribute overrides the {{htmlattrxref("action","form")}} attribute of the element's form owner.</dd>
+ <dt>{{htmlattrdef("formenctype")}} {{HTMLVersionInline("5")}}</dt>
+ <dd>If the input element is a submit button or image, this attribute specifies the content encoding that is used to submit the form data to the server. Possible values:
+ <ul>
+ <li><code>application/x-www-form-urlencoded</code>: The default value if the attribute is not specified.</li>
+ <li><code>multipart/form-data</code>: Use this value if you are using an <code>&lt;input&gt;</code> element with the {{htmlattrxref("type","input")}} attribute set to <code>file</code>.</li>
+ <li><code>text/plain</code>: This encoding is mostly for debugging.</li>
+ </ul>
+
+ <p>This attribute overrides the {{htmlattrxref("enctype","form")}} attribute of the element's form owner.</p>
+ </dd>
+ <dt>{{htmlattrdef("formmethod")}} {{HTMLVersionInline("5")}}</dt>
+ <dd>If the input element is a submit button or image, this attribute specifies the <a href="/en-US/docs/Glossary/Method">HTTP method</a> that the browser uses to submit the form. Possible values:
+ <ul>
+ <li><code>post</code>: The data from the form is included in the body of the form and is sent to the server.</li>
+ <li><code>get</code>: The data from the form are appended to the <strong>form</strong> attribute URL, with a '?' as a separator, and the resulting URL is sent to the server. Use this method when the form has no side-effects and contains only ASCII characters.</li>
+ </ul>
+
+ <p>This attribute overrides the {{htmlattrxref("method","form")}} attribute of the element's form owner.</p>
+ </dd>
+ <dt>{{htmlattrdef("formnovalidate")}} {{HTMLVersionInline("5")}}</dt>
+ <dd>If the input element is a submit button or image, this Boolean attribute specifies that the form shouldn't be validated before submission. This attribute overrides the {{htmlattrxref("novalidate","form")}} attribute of the element's form owner.</dd>
+ <dt>{{htmlattrdef("formtarget")}} {{HTMLVersionInline("5")}}</dt>
+ <dd>If the input element is a submit button or image, this attribute is a name or keyword indicating where to display the response that is received by submitting the form. This is a name of, or keyword for, a <em>browsing context</em> (e.g. tab, window, or <a href="/en-US/docs/Web/HTML/Element/iframe">inline frame</a>). This attribute overrides the {{htmlattrxref("target", "form")}} attribute of the elements's form owner. The following keywords have special meanings:
+ <ul>
+ <li>_<code>self</code>: Load the response into the same browsing context as the current one. This is the default if the attribute is not specified.</li>
+ <li><code>_blank</code>: Load the response into a new unnamed browsing context.</li>
+ <li><code>_parent</code>: Load the response into the parent browsing context of the current one. If there is no parent, this option behaves the same way as <code>_self</code>.</li>
+ <li><code>_top</code>: Load the response into the top-level browsing context (i.e. the browsing context that is an ancestor of the current one, and has no parent). If there is no parent, this option behaves the same way as <code>_self</code>.</li>
+ </ul>
+ </dd>
+ <dt>{{htmlattrdef("height")}} {{HTMLVersionInline("5")}}</dt>
+ <dd>If the value of the <strong>type</strong> attribute is <code>image</code>, defines the height of the image displayed for the button in pixels.</dd>
+ <dt>{{htmlattrdef("inputmode")}} {{HTMLVersionInline("5")}}</dt>
+ <dd>A hint to browsers for which virtual keyboard to display. This attribute applies when the the <strong>type</strong> attribute is text, password, email, or url. Possible values:
+ <ul>
+ <li><code>none</code>: No virtual keyboard should be displayed.</li>
+ <li><code>text</code>: Text input in the user's locale.</li>
+ <li><code>decimal</code>: Fractional numeric input.</li>
+ <li><code>numeric</code>: Numeric input.</li>
+ <li><code>tel</code>: Telephone input, including asterisk and pound key. Prefer <code>&lt;input type="tel"&gt;</code>.</li>
+ <li><code>search</code>: A virtual keyboard optimized for search input.</li>
+ <li><code>email</code>: Email input. Prefer <code>&lt;input type="email"&gt;</code>.</li>
+ <li><code>url</code>: URL input. Prefer <code>&lt;input type="url"&gt;</code>.</li>
+ </ul>
+
+ <div class="warning">
+ <div class="important"><strong>Spec conflict</strong>: The <a href="https://html.spec.whatwg.org/multipage/interaction.html#attr-inputmode">WHATWG spec lists <code>inputmode</code></a>, and modern browsers are working towards supporting it. The <a href="https://www.w3.org/TR/html52/index.html#contents">W3C HTML 5.2 spec</a> however no longer lists it (i.e. marks it as obsolete). You should consider the WHATWG definition as correct, until a consensus is reached.</div>
+ </div>
+ </dd>
+ <dt>{{htmlattrdef("list")}} {{HTMLVersionInline("5")}}</dt>
+ <dd>Points to a {{HTMLElement("datalist")}} of predefined options to suggest to the user. The value must be the <strong>id</strong> of a <code>&lt;datalist&gt;</code> element in the same document. Browsers display only valid options for the input. This attribute is ignored when the <strong>type</strong> attribute is <code>hidden</code>, <code>checkbox</code>, <code>radio</code>, <code>file</code>, or a button type.</dd>
+ <dt>{{htmlattrdef("max")}} {{HTMLVersionInline("5")}}</dt>
+ <dd>The maximum (numeric or date-time) value for the input. Must not be less than its minimum (<strong>min</strong> attribute) value.</dd>
+ <dt>{{htmlattrdef("maxlength")}}</dt>
+ <dd>If the value of the <strong>type</strong> attribute is <code>text</code>, <code>email</code>,<code> search</code>, <code>password</code>, <code>tel</code>, or <code>url</code>, this attribute specifies the maximum number of characters (in UTF-16 code units) that the user can enter. For other control types, it is ignored.</dd>
+ <dt>{{htmlattrdef("min")}} {{HTMLVersionInline("5")}}</dt>
+ <dd>The minimum (numeric or date-time) value for this input, which must not be greater than its maximum (<strong>max</strong> attribute) value.</dd>
+ <dt>{{htmlattrdef("minlength")}} {{HTMLVersionInline("5")}}</dt>
+ <dd>If the value of the <strong>type</strong> attribute is <code>text</code>, <code>email</code>,<code> search</code>, <code>password</code>, <code>tel</code>, or <code>url</code>, this attribute specifies the minimum number of characters (in UTF-16 code points) that the user can enter. For other control types, it is ignored.</dd>
+ <dt>{{htmlattrdef("multiple")}} {{HTMLVersionInline("5")}}</dt>
+ <dd>This Boolean attribute indicates whether the user can enter more than one value. This attribute only applies when the <strong>type</strong> attribute is set to <code>email</code> or <code>file</code>.</dd>
+ <dt>{{htmlattrdef("name")}}</dt>
+ <dd>The name of the control, which is submitted with the control's value as part of the form data. If no name is specified or it is empty, the control's value is not submitted with the form.</dd>
+ <dt>{{htmlattrdef("pattern")}} {{HTMLVersionInline("5")}}</dt>
+ <dd>A regular expression that the control's value is checked against. The pattern must match the entire value. Use the <strong>title</strong> attribute to describe the pattern to help the user. This attribute only applies when the value of the <strong>type</strong> attribute is <code>text</code>, <code>search</code>, <code>tel</code>, <code>url</code>, <code>email</code>, or <code>password</code>. The regular expression language is the same as the JavaScript {{jsxref("RegExp")}} algorithm, with the <code>'u'</code> parameter that makes it treat the pattern as a sequence of unicode code points. The pattern is not surrounded by forward slashes.</dd>
+ <dt>{{htmlattrdef("placeholder")}} {{HTMLVersionInline("5")}}</dt>
+ <dd>A hint to the user of what can be entered in the control, typically in the form of an example of the type of information that should be entered. The placeholder text <em>must not</em> contain carriage returns or line-feeds.
+ <div class="note"><strong>Note:</strong> Before using <code>placeholder</code>, please see the section {{anch("Labels and placeholders")}} to ensure that you use them correctly if at all. Placeholders can be confusing and can disrupt certain operations in unexpected ways.</div>
+ </dd>
+ <dt>{{htmlattrdef("readonly")}} {{HTMLVersionInline("5")}}</dt>
+ <dd>This Boolean attribute prevents the user from modifying the value of the input. It is ignored if the value of the <strong>type</strong> attribute is <code>hidden</code>, <code>range</code>, <code>color</code>, <code>checkbox</code>, <code>radio</code>, <code>file</code>, or a button type (such as <code>button</code> or <code>submit</code>).</dd>
+ <dt>{{htmlattrdef("required")}} {{HTMLVersionInline("5")}}</dt>
+ <dd>This attribute specifies that the user must fill in a value before submitting a form. It cannot be used when the <strong>type</strong> attribute is <code>hidden</code>, <code>image</code>, or a button type (<code>submit</code>, <code>reset</code>, or <code>button</code>). The {{cssxref(":optional")}} and {{cssxref(":required")}} CSS pseudo-classes will be applied to the field as appropriate.</dd>
+ <dt>{{htmlattrdef("size")}}</dt>
+ <dd>The initial size of the control. Starting in HTML5, this attribute applies only when the <strong>type</strong> attribute is set to <code>text</code>, <code>search</code>, <code>tel</code>, <code>url</code>, <code>email</code>, or <code>password</code>, otherwise it is ignored. The size must be an integer greater than zero. The default value is 20.</dd>
+ <dd>HTML5 states "the user agent should ensure that at least that many characters are visible", but different characters have different widths in certain fonts. In some browsers, a certain string with <em>x</em> characters will not be entirely visible even if <code>size</code> is defined as <em>x</em>.</dd>
+ <dt>{{htmlattrdef("spellcheck")}} {{HTMLVersionInline("5")}}</dt>
+ <dd>Setting the value of this attribute to <code>true</code> indicates that the element needs to have its spelling and grammar checked. The value <code>default</code> indicates that the element is to act according to a default behavior, possibly based on the parent element's own <code>spellcheck</code> value. The value <code>false</code> indicates that the element should not be checked.</dd>
+ <dt>{{htmlattrdef("src")}}</dt>
+ <dd>If the value of the <strong>type</strong> attribute is <code>image</code>, this attribute specifies the URL of the image file to display on the graphical submit button.</dd>
+ <dt>{{htmlattrdef("step")}} {{HTMLVersionInline("5")}}</dt>
+ <dd>Works with the <strong>min</strong> and <strong>max</strong> attributes to limit the increments at which a numeric or date-time value can be set. It can be the string <code>any</code> or a positive floating point number. If this attribute is not set to <code>any</code>, the control accepts only values at multiples of the step value greater than the minimum.</dd>
+ <dt>{{htmlattrdef("tabindex")}} element-specific in {{HTMLVersionInline(4)}}, global in {{HTMLVersionInline("5")}}</dt>
+ <dd>The position of the element in the tabbing navigation order for the current document.</dd>
+ <dt>{{htmlattrdef("usemap")}} {{HTMLVersionInline(4)}} only, {{obsoleteGeneric("inline", "HTML5")}}</dt>
+ <dd>The name of a {{HTMLElement("map")}} element to be used as an image map.</dd>
+ <dt>{{htmlattrdef("value")}}</dt>
+ <dd>The initial value of the control. This attribute is optional except when the value of the <strong>type</strong> attribute is <code>radio</code> or <code>checkbox</code>.</dd>
+ <dd>When reloading the page, Firefox and IE <a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=46845#c186">will ignore the value specified in the HTML source</a>, if the value was changed before the reload.</dd>
+ <dt>{{htmlattrdef("width")}} {{HTMLVersionInline("5")}}</dt>
+ <dd>If the value of the <strong>type</strong> attribute is <code>image</code>, this attribute defines the width of the image displayed for the button in pixels.</dd>
+</dl>
+
+<h3 id="Non-standard_&lt;input>_attributes">Non-standard <code>&lt;input&gt;</code> attributes</h3>
+
+<dl>
+ <dt>{{htmlattrdef("autocorrect")}} {{non-standard_inline}}</dt>
+ <dd>This is a non-standard attribute supported by Safari that is used to control whether autocorrection should be enabled when the user is entering/editing the text value of the <code>&lt;input&gt;</code>. Possible attribute values are:
+ <ul>
+ <li><code>on</code>: Enable autocorrection.</li>
+ <li><code>off</code>: Disable autocorrection.</li>
+ </ul>
+ <a href="https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/Attributes.html#//apple_ref/doc/uid/TP40008058-autocorrect"><code>autocorrect</code> documentation</a> in the Safari HTML Reference.</dd>
+ <dt>{{htmlattrdef("incremental")}} {{non-standard_inline}}</dt>
+ <dd>This is a nonstandard attribute supported by WebKit (Safari) and Blink (Chrome) that only applies when the <strong>type</strong> is <code>search</code>. If the attribute is present, regardless of what its value is, the <code>&lt;input&gt;</code> fires <a href="/en-US/docs/Web/Events/search"><code>search</code></a> events as the user edits the text value. The event is only fired after an implementation-defined timeout has elapsed since the most recent keystroke, and new keystrokes reset the timeout. In other words, the event firing is debounced. If the attribute is absent, the <a href="/en-US/docs/Web/Events/search"><code>search</code></a> event is only fired when the user explicitly initiates a search (e.g. by pressing the Enter key while within field). <a href="https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/Attributes.html#//apple_ref/doc/uid/TP40008058-incremental"><code>incremental</code> documentation in the Safari HTML Reference</a></dd>
+ <dt>{{htmlattrdef("mozactionhint")}} {{non-standard_inline}}</dt>
+ <dd>Specifies an "action hint" used to determine how to label the enter key on mobile devices with virtual keyboards. Supported values are <code>go</code>, <code>done</code>, <code>next</code>, <code>search</code>, and <code>send</code>. These automatically get mapped to the appropriate string and are case-insensitive.</dd>
+ <dt>{{htmlattrdef("results")}} {{non-standard_inline}}</dt>
+ <dd>This is a nonstandard attribute supported by Safari that only applies when the <strong>type</strong> is <code>search</code>. It is used to control the maximum number of entries that should be displayed in the <code>&lt;input&gt;</code>'s native dropdown list of past search queries. Its value should be a nonnegative decimal integer.</dd>
+ <dt>{{htmlattrdef("webkitdirectory")}} {{non-standard_inline}}</dt>
+ <dd>This Boolean attribute indicates if the selector used when the <strong>type</strong> attribute is <code>file</code> has to allow for the selection of directories only.</dd>
+ <dt>{{htmlattrdef("x-moz-errormessage")}} {{non-standard_inline}}</dt>
+ <dd>This Mozilla extension allows you to specify the error message to display when a field doesn't successfully validate.</dd>
+</dl>
+
+<h2 id="Styling_input_elements">Styling input elements</h2>
+
+<p>You can style <code>&lt;input&gt;</code> elements using various color-related attributes in particular. One unusual one that is specific to text entry-related elements is the CSS {{cssxref("caret-color")}} property, which lets you set the color used to draw the text input caret:</p>
+
+<h3 id="HTML">HTML</h3>
+
+<pre class="brush: html">&lt;label for="textInput"&gt;Note the red caret:&lt;/label&gt;
+&lt;input id="textInput" class="custom" size="32"/&gt;
+</pre>
+
+<h3 id="CSS">CSS</h3>
+
+<pre class="brush: css">input.custom {
+ caret-color: red;
+ font: 16px "Helvetica", "Arial", "sans-serif"
+}
+</pre>
+
+<h3 id="Result">Result</h3>
+
+<p>{{EmbedLiveSample('Styling_input_elements', 500, 80)}}</p>
+
+<p>For more information about adding color to elements in HTML, see <a href="/en-US/docs/Web/HTML/Applying_color">Applying color to HTML elements using CSS</a>.</p>
+
+<h2 id="Labels_and_placeholders">Labels and placeholders</h2>
+
+<div class="note">
+<p><strong>TL;DR:</strong> To save you time, here's the key point: don't use the {{htmlattrxref("placeholder", "input")}} attribute if you can avoid it. If you need to label an <code>&lt;input&gt;</code> element, use the {{HTMLElement("label")}} element.</p>
+</div>
+
+<p>There are three seemingly similar ways to associate assistive text with an <code>&lt;input&gt;</code>. However, they are actually quite different, and only one of them is always a good choice. Here we will look at each of them and learn best practices for providing the user with guidance when entering data into a form.</p>
+
+<h3 id="The_&lt;label>_element">The &lt;label&gt; element</h3>
+
+<p>The {{HTMLElement("label")}} element is the only way to provide explanatory information about a form field that is <em>always</em> appropriate (aside from any layout concerns you have). It's never a bad idea to use a <code>&lt;label&gt;</code> to explain what should be entered into an <code>&lt;input&gt;</code> or {{HTMLElement("textarea")}}.</p>
+
+<h3 id="The_placeholder_attribute">The placeholder attribute</h3>
+
+<p>The {{htmlattrxref("placeholder", "input")}} attribute lets you specify a prompt that appears within the <code>&lt;input&gt;</code> element's content area itself when empty. It's intended to be used to show an example input, rather than an explanation or prompt, but tends to be badly misused.</p>
+
+<p>Here are two inputs that take a password, each with a placeholder:</p>
+
+<p><img alt="Example of correct and incorrect placeholder usage" src="https://mdn.mozillademos.org/files/16094/placeholder-badgood.png" style="border-style: solid; border-width: 1px; height: 66px; width: 230px;"></p>
+
+<p>The first one uses a placeholder string <code>"MyGr8P@sswrd"</code>, demonstrating what a password might look like. And no, that's not <em>really</em> a great password.</p>
+
+<p>The second one uses a prompt string, <code>"Enter your password"</code> as a placeholder. The first, and most obvious, problem with doing this is that as soon as the user types their first character, they no longer have a prompt explaining what that field is for.</p>
+
+<p>That's why, instead, you should use the {{HTMLElement("label")}} element. The placeholder should never be required in order to understand your forms. While some people are able to remember what a given empty box is meant for after its only identifying text vanishes, others cannot.</p>
+
+<p>If the user can't understand your form if the placeholders are missing (say, in a browser that doesn't support <code>placeholder</code>, or in the case above where the user starts typing then gets confused), you're not using placeholders properly.</p>
+
+<p>In addition, browsers with automatic page translation features may skip over attributes when translating. That means the <code>placeholder</code> may not get translated, resulting in important information not being translated.</p>
+
+<p>If you feel like you need to use a placeholder, it's possible to use both a placeholder and a label:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/16110/label-and-placeholder.png" style="border-style: solid; border-width: 1px; height: 48px; width: 234px;"></p>
+
+<ul>
+</ul>
+
+<h3 id="Unadorned_text_adjacent_to_the_&lt;input>_element">Unadorned text adjacent to the &lt;input&gt; element</h3>
+
+<p>You can also just have plain text adjacent to the <code>&lt;input&gt;</code> element, like this:</p>
+
+<pre class="brush: html">&lt;p&gt;Enter your name: &lt;input id="name" type="text" size="30"&gt;&lt;/p&gt;</pre>
+
+<p>Please don't do this. This doesn't create a relationship between the prompt and the <code>&lt;input&gt;</code> element, which is important for reasons we'll get into in the next section.</p>
+
+<h3 id="Why_you_should_use_labels">Why you should use labels</h3>
+
+<p>In addition to the information provided above, there are a number of other reasons why <code>&lt;label&gt;</code> is the best way to explain <code>&lt;input&gt;</code>s:</p>
+
+<ul>
+ <li>The semantic pairing of <code>&lt;input&gt;</code> and <code>&lt;label&gt;</code> elements is useful for assistive technologies such as screen readers. By pairing them using the <code>&lt;label&gt;</code>'s {{htmlattrxref("for", "label")}} attribute, you bond the label to the input in a way that lets screen readers describe inputs to users more precisely.</li>
+ <li>By pairing a <code>&lt;label&gt;</code> with an <code>&lt;input&gt;</code>, clicking on either one will focus the <code>&lt;input&gt;</code>. If you use plaintext to "label" your input, this won't happen. Having the prompt part of the activation area for the input is helpful for people with motor control conditions.</li>
+ <li>As web developers, it's important that we never assume that people will know all the things that we know. The diversity of people using the web—and by extension your web site—practically guarantees that some of your site's visitors will have some variation in thought processes and/or circumstances that leads them to interpret your forms very differently from you without clear and properly-presented labels.</li>
+</ul>
+
+<h2 id="Examples">Examples</h2>
+
+<p>You can find multiple examples of <code>&lt;input&gt;</code> element usage on the pages covering each individual type — see {{anch("Form &lt;input&gt; types")}}, and also see the {{anch("Live example")}} at the top of the article.</p>
+
+<ul>
+</ul>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('HTML WHATWG', 'forms.html#the-input-element', '&lt;input&gt;')}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML Media Capture', '#the-capture-attribute','&lt;input capture&gt;')}}</td>
+ <td>{{Spec2('HTML Media Capture')}}</td>
+ <td>Adds the <code>capture</code> element</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML5 W3C', 'forms.html#the-input-element', '&lt;input&gt;')}}</td>
+ <td>{{Spec2('HTML5 W3C')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML4.01', 'interact/forms.html#h-17.4', '&lt;form&gt;')}}</td>
+ <td>{{Spec2('HTML4.01')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+
+
+<p>{{Compat("html.elements.input")}}</p>
+
+<p>{{CompatibilityTable}}</p>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Chrome</th>
+ <th>Edge</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>1.0</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoDesktop("1.7")}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>1.0</td>
+ <td>1.0</td>
+ </tr>
+ <tr>
+ <td><code>type="time"</code></td>
+ <td>20</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoDesktop(57)}}</td>
+ <td>{{CompatNo}}</td>
+ <td>10.62</td>
+ <td>{{CompatNo}}<sup>[1]</sup></td>
+ </tr>
+ <tr>
+ <td><code>accept</code></td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>10</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ </tr>
+ <tr>
+ <td><code>mozactionhint</code></td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatGeckoDesktop("2.0")}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ </tr>
+ <tr>
+ <td><code>autocapitalize</code></td>
+ <td>43</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatVersionUnknown}}<sup> [3]</sup></td>
+ </tr>
+ <tr>
+ <td><code>autofocus</code>, <code>max</code>, <code>min</code>, <code>pattern</code>, <code>placeholder</code>, <code>required</code>, <code>step</code>, <code>list</code>, <code>multiple</code></td>
+ <td>5.0</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>10</td>
+ <td>9.6</td>
+ <td>5.0</td>
+ </tr>
+ <tr>
+ <td>capture</td>
+ <td>Chrome for Android (0.16)</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ <tr>
+ <td><a href="https://html.spec.whatwg.org/multipage/forms.html#fakepath-srsly">fakepath</a> added to file input values</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatGeckoDesktop("53")}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ <tr>
+ <td><code>form</code></td>
+ <td>10</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>4</td>
+ <td>{{CompatNo}}<sup>[7]</sup></td>
+ <td>9.5</td>
+ <td>5.0</td>
+ </tr>
+ <tr>
+ <td><code>formaction</code>, <code>formenctype</code>, <code>formmethod</code>, <code>formnovalidate</code>, <code>formtarget</code></td>
+ <td>9.0</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoDesktop("2.0")}}</td>
+ <td>10</td>
+ <td>10.62</td>
+ <td>5.1</td>
+ </tr>
+ <tr>
+ <td><code>incremental</code></td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ <tr>
+ <td><code>inputmode</code></td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatGeckoDesktop("17")}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ </tr>
+ <tr>
+ <td><code>minlength</code></td>
+ <td>40.0</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ <tr>
+ <td><code>readonly</code></td>
+ <td>1.0</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoDesktop("1.7")}}</td>
+ <td>6<sup>[2] </sup></td>
+ <td>1.0</td>
+ <td>1.0</td>
+ </tr>
+ <tr>
+ <td><code>spellcheck</code></td>
+ <td>10.0</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatGeckoDesktop("1.9.2")}}</td>
+ <td>10</td>
+ <td>11.0</td>
+ <td>4.0</td>
+ </tr>
+ <tr>
+ <td><code>webkitdirectory</code></td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoDesktop("49.0")}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Android</th>
+ <th>Edge</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoMobile("2.0")}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ <tr>
+ <td><code>type="time"</code></td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoDesktop(57)}}</td>
+ <td>{{CompatNo}}</td>
+ <td>10.62</td>
+ <td>{{CompatVersionUnknown}}<sup>[1]</sup></td>
+ </tr>
+ <tr>
+ <td><code>accept</code></td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ <tr>
+ <td><code>autocapitalize</code></td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatVersionUnknown}}<sup>[3]</sup></td>
+ </tr>
+ <tr>
+ <td><code>autofocus</code>, <code>max</code>, <code>min</code>, <code>pattern</code>, <code>placeholder</code>, <code>required</code>, <code>step</code>, <code>list</code>, <code>multiple</code></td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}<sup>[5]</sup></td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ <tr>
+ <td><code>capture</code></td>
+ <td>3.0</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatGeckoMobile("10.0")}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>6.0</td>
+ </tr>
+ <tr>
+ <td><a href="https://html.spec.whatwg.org/multipage/forms.html#fakepath-srsly">fakepath</a> added to file input values</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatGeckoMobile("53")}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ <tr>
+ <td><code>form</code>, <code>formaction</code>, <code>formenctype</code>, <code>formmethod</code>, <code>formnovalidate</code>, <code>formtarget</code></td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ <tr>
+ <td><code>minlength</code></td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>27.0</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ <tr>
+ <td><code>spellcheck</code></td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatGeckoMobile("2.0")}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>11.0</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ <tr>
+ <td><code>webkitdirectory</code></td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoMobile("49.0")}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<p>[1] It is recognized but there is no UI.</p>
+
+<p>[2] Missing for <code>type="checkbox"</code> and <code>type="radio"</code>.</p>
+
+<p>[3] In Safari <code>autocapitalize="words"</code> capitalizes every word's second character.</p>
+
+<p>[4] <code>datetime</code> has been removed from the spec and browsers in favour of <code>datetime-local</code>.</p>
+
+<p>[5] see {{bug(1355389)}}</p>
+
+<p>[6] Not yet implemented. For progress, see {{bug("888320")}} and <a href="https://wiki.mozilla.org/TPE_DOM/Date_time_input_types">TPE DOM/Date time input types</a>.</p>
+
+<h2 id="Notes">Notes</h2>
+
+<h3 id="File_inputs">File inputs</h3>
+
+<ol>
+ <li>
+ <p>Starting in {{Gecko("2.0")}}, calling the <code>click()</code> method on an <code>&lt;input&gt;</code> element of type <code>file</code> opens the file picker and lets the user select files. See <a href="/en-US/docs/Using_files_from_web_applications">Using files from web applications</a> for an example and more details.</p>
+ </li>
+ <li>
+ <p>You cannot set the value of a file picker from a script — doing something like the following has no effect:</p>
+
+ <pre class="brush: js">var e = getElementById("someFileInputElement");
+e.value = "foo";
+</pre>
+ </li>
+ <li>
+ <p>When a file is chosen using an <code>&lt;input type="file"&gt;</code>, the real path to the source file is not shown in the input's <code>value</code> attribute for obvious security reasons. Instead, the filename is shown, with <code>C:\fakepath\</code> appended to the beginning of it. There are some historical reasons for this quirk, but it is supported across all modern browsers, and in fact is <a href="https://html.spec.whatwg.org/multipage/forms.html#fakepath-srsly">defined in the spec</a>.</p>
+ </li>
+</ol>
+
+<h3 id="Error_messages">Error messages</h3>
+
+<p>If you want Firefox to present a custom error message when a field fails to validate, you can use the <code>x-moz-errormessage</code> attribute to do so:</p>
+
+<pre class="brush: html">&lt;input type="email"
+ x-moz-errormessage="Please specify a valid email address."&gt;
+</pre>
+
+<p>Note, however, that this is not standard and will not have an effect on other browsers.</p>
+
+<h3 id="Localization">Localization</h3>
+
+<p>The allowed inputs for certain &lt;input&gt; types depend on the locale. In some locales, 1,000.00 is a valid number, while in other locales the valid way to enter this number is 1.000,00.</p>
+
+<p>Firefox uses the following heuristics to determine the locale to validate the user's input (at least for <code>type="number"</code>):</p>
+
+<ul>
+ <li>Try the language specified by a <code>lang</code>/<code>xml:lang</code> attribute on the element or any of its parents.</li>
+ <li>Try the language specified by any Content-Language HTTP header or</li>
+ <li>If none specified, use the browser's locale.</li>
+</ul>
+
+<h3 id="Using_mozactionhint_on_Firefox_mobile">Using mozactionhint on Firefox mobile</h3>
+
+<p>You can use the {{htmlattrxref("mozactionhint", "input")}} attribute to specify the text for the label of the enter key on the virtual keyboard when your form is rendered on Firefox mobile. For example, to have a "Next" label, you can do this:</p>
+
+<pre class="brush: html">&lt;input type="text" mozactionhint="next"&gt;
+</pre>
+
+<p>The result is:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/3251/mozactionhint.png" style="border-style: solid; border-width: 1px; height: 400px; width: 240px;"></p>
+
+<p>Note the "Next" key in the lower-right corner of the keyboard.</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li>Other form-related elements: {{HTMLElement("form")}}, {{HTMLElement("button")}}, {{HTMLElement("datalist")}}, {{HTMLElement("legend")}}, {{HTMLElement("label")}}, {{HTMLElement("select")}}, {{HTMLElement("optgroup")}}, {{HTMLElement("option")}}, {{HTMLElement("textarea")}}, {{HTMLElement("keygen")}}, {{HTMLElement("fieldset")}}, {{HTMLElement("output")}}, {{HTMLElement("progress")}} and {{HTMLElement("meter")}}.</li>
+ <li><a href="/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation">Form constraint validation</a></li>
+ <li><a class="external" href="http://webdesignerwall.com/tutorials/cross-browser-html5-placeholder-text">Cross-browser HTML5 placeholder text</a></li>
+ <li>The CSS {{cssxref("caret-color")}} property</li>
+ <li>In certain cases (typically involving non-textual inputs and specialized interfaces), the <code>&lt;input&gt;</code> element is a <a href="/en-US/docs/Web/CSS/Replaced_element">replaced element</a>. When it is, the position and size of the elemnt's size and positioning within its frame can be adjusted using the CSS {{cssxref("object-position")}} and {{cssxref("object-fit")}} properties</li>
+</ul>