Атрибут autocomplete HTML тега <form>

Значение и применение

Логический атрибут autocomplete (HTML тега <form>) указывает может ли браузер автоматически заполнять элементы формы (по умолчанию - включен). Этот атрибут помогает заполнять поля форм текстом, который был введён в них ранее (если не отключено настройками браузера).

Значение атрибута может быть переопределено с помощью атрибута autocomplete элементов, относящихся к форме.

Поддержка браузерами

Спецификация: multipage

Поддерживается во всех основных браузерах с 2015 года.

Отдельные значения (1) поддерживаются не везде — смотрите таблицу.

Показать браузеры
Совместимостьhtml.elements.form.autocomplete
ВозможностьКомпьютерыМобильные
ChromeEdgeFirefoxOperaSafariChrome AndroidFirefox for AndroidOpera AndroidSafari on iOSSamsung BrowserWebView AndroidWebView on iOS
autocomplete✓14

14

Примечание MDN (англ.)

The Google Chrome UI for auto-complete request varies, depending on whether autocomplete is set to off on <input> elements as well as their form. Specifically, when a form has autocomplete set to off and its <input> element's autocomplete attribute is not set, then if the user asks for autofill suggestions for the <input> element, Chrome might display a message saying 'autocomplete has been disabled for this form.' On the other hand, if both the form and the input element have autocomplete set to off, the browser will not display that message. For this reason, you should set autocomplete to off for each <input> that has custom auto-completion.

✓12✓4✓15

15

Примечание MDN (англ.)

The Opera UI for auto-complete request varies, depending on whether autocomplete is set to off on <input> elements as well as their form. Specifically, when a form has autocomplete set to off and its <input> element's autocomplete attribute is not set, then if the user asks for autofill suggestions for the <input> element, Opera might display a message saying 'autocomplete has been disabled for this form.' On the other hand, if both the form and the input element have autocomplete set to off, the browser will not display that message. For this reason, you should set autocomplete to off for each <input> that has custom auto-completion.

✓6✓18

18

Примечание MDN (англ.)

The Chrome Android UI for auto-complete request varies, depending on whether autocomplete is set to off on <input> elements as well as their form. Specifically, when a form has autocomplete set to off and its <input> element's autocomplete attribute is not set, then if the user asks for autofill suggestions for the <input> element, Chrome Android might display a message saying 'autocomplete has been disabled for this form.' On the other hand, if both the form and the input element have autocomplete set to off, the browser will not display that message. For this reason, you should set autocomplete to off for each <input> that has custom auto-completion.

✓4✓14

14

Примечание MDN (англ.)

The Opera Android UI for auto-complete request varies, depending on whether autocomplete is set to off on <input> elements as well as their form. Specifically, when a form has autocomplete set to off and its <input> element's autocomplete attribute is not set, then if the user asks for autofill suggestions for the <input> element, Opera Android might display a message saying 'autocomplete has been disabled for this form.' On the other hand, if both the form and the input element have autocomplete set to off, the browser will not display that message. For this reason, you should set autocomplete to off for each <input> that has custom auto-completion.

✓6✓1.0

1.0

Примечание MDN (англ.)

The Samsung Browser UI for auto-complete request varies, depending on whether autocomplete is set to off on <input> elements as well as their form. Specifically, when a form has autocomplete set to off and its <input> element's autocomplete attribute is not set, then if the user asks for autofill suggestions for the <input> element, Samsung Browser might display a message saying 'autocomplete has been disabled for this form.' On the other hand, if both the form and the input element have autocomplete set to off, the browser will not display that message. For this reason, you should set autocomplete to off for each <input> that has custom auto-completion.

✓4.4

4.4

Примечание MDN (англ.)

The WebView Android UI for auto-complete request varies, depending on whether autocomplete is set to off on <input> elements as well as their form. Specifically, when a form has autocomplete set to off and its <input> element's autocomplete attribute is not set, then if the user asks for autofill suggestions for the <input> element, WebView Android might display a message saying 'autocomplete has been disabled for this form.' On the other hand, if both the form and the input element have autocomplete set to off, the browser will not display that message. For this reason, you should set autocomplete to off for each <input> that has custom auto-completion.

✓6
new-password✓69✓79✓69✓56✓10✓69✓79✓48✓10✓10.0✓69✓10
one-time-code✓93✓93✓109✓79✓12✓84✓109✓60✓12✓14.0×✓12
webauthn✓108✓108✓122✓94✓16.4✓108✓122✓73✓16.4✓21.0✓108✓16.4

поддерживается с ограничениями нет поддержки нет данных≤31 — не позднее версии 31

Синтаксис:

HTML
<form autocomplete = "on | off">

Значения атрибута

ЗначениеОписание
onБраузер автоматически заполняет значения на основе тех значений, которые пользователь вводил ранее. Это значение по умолчанию.
offПользователь должен вводить значения в каждом поле формы после каждого использования. Браузер не может автоматически подставлять значения.

Отличия HTML 4.01 от HTML 5

Атрибут считается новым в HTML 5.

Пример использования

HTML
<!DOCTYPE html>
<html>
  <head>
    <title>Пример использования атрибута autocomplete HTML тега <button></title>
  </head>
  <body>
    <form action="somepage.php" autocomplete="on">
      <!-- указываем адрес, куда отправляется форма и указываем, что проверка данных на корректность, введенных пользователем в форму не производится -->
      Name: <input type="text" name="f-name" /><br />
      <!-- определяет однострочное текстовое поле -->
      E-mail: <input type="email" name="e-mail" /><br />
      <!-- определяем элемент управления для ввода адреса электронной почты -->
      Your phone: <input type="tel" name="user-phone" /><br />
      <!-- определяем элемент управления для ввода телефонного номера -->
      <input type="submit" />
      <!-- определяем кнопку отправки формы -->
    </form>
  </body>
</html>

В данном примере мы создали форму (HTML тег <form>), указали адрес, куда она отправляется и логическим атрибутом autocomplete указали, что браузер может автоматически заполнять элементы формы. Кроме того, мы разместили элемент управления для ввода телефонного номера, имени пользователя, адреса его электронной почты и кнопку отправки формы.

Результат нашего примера:

Пример использования атрибута autocomplete HTML тега <form>.
Пример использования атрибута autocomplete HTML тега <form>.