The HTML autocomplete attribute
autocomplete está disponible en varios tipos de
<input> aquellos que toman un texto o valor numérico como entrada.
autocomplete permite a los desarrolladores web especificar qué permisos si los hay user agent debe proporcionar asistencia automatizada para completar los valores de los campos de formulario, así como una guía para el navegador en cuanto al tipo de información que se espera en el campo.
Los valores sugeridos generalmente depende del navegador. Normalmente, provienen de valores ingresados por el usuario, pero también pueden provenir de valores preconfigurados. Por ejemplo, un navegador puede permitir que el usuario guarde su nombre, dirección, número de teléfono y direcciones de correo electrónico para autocompletar así como también datos de tarjetas de crédito.
Si un elemento
<input> no tiene el atributo
autocomplete , entonces los navegadores usan el atributo
<form> que lo contiene. En otras palabras, el
<form> del que el
<input> desciende. También puede ser especificado en el atributo
<input> en cuestión.
Para proveer el autocompletado, el navegador necesita del los elementos
- Que tengan
- Pertenezcan a un elemento
- Que el formulario tenga un botón submit
- The browser is not permitted to automatically enter or select a value for this field. It is possible that the document or application provides its own autocomplete feature, or that security concerns require that the field's value not be automatically entered.
Note: In most modern browsers, setting
"off"will not prevent a password manager from asking the user if they would like to save username and password information, or from automatically filling in those values in a site's login form. See the autocomplete attribute and login fields.
- The browser is allowed to automatically complete the input. No guidance is provided as to the type of data expected in the field, so the browser may use its own judgement.
- The field expects the value to be a person's full name. Using
"name"rather than breaking the name down into its components is generally preferred because it avoids dealing with the wide diversity of human names and how they are structured; however, you can use the following
autocompletevalues if you do need to break the name down into its components:
- The prefix or title, such as "Mrs.", "Mr.", "Miss", "Ms.", "Dr.", or "Mlle.".
- The given (or "first") name.
- The middle name.
- The family (or "last") name.
- The suffix, such as "Jr.", "B.Sc.", "PhD.", "MBASW", or "IV".
- A nickname or handle.
- An email address.
- A username or account name.
- A new password. When creating a new account or changing passwords, this is the "Enter your new password" field, as opposed to any "Enter your current password" field that might be present. This may be used by the browser both to avoid accidentally filling in an existing password and to offer assistance in creating a secure password.
- The user's current password.
- A job title, or the title a person has within an organization, such as "Senior Technical Writer", "President", or "Assistant Troop Leader".
- A company or organization name, such as "Acme Widget Company" or "Girl Scouts of America".
- A street address. This can be multiple lines of text, and should fully identify the location of the address within its second administrative level (typically a city or town), but should not include the city name, ZIP or postal code, or country name.
- Each individual line of the street address. These should only be present if the
"street-address"is also present.
- The finest-grained administrative level, in addresses which have four levels.
- The third administrative level, in addresses with at least three administrative levels.
- The second administrative level, in addresses with at least two of them. In countries with two administrative levels, this would typically be the city, town, village, or other locality in which the address is located.
- The first administrative level in the address. This is typically the province in which the address is located. In the United States, this would be the state. In Switzerland, the canton. In the United Kingdom, the post town.
- A country code.
- A country name.
- A postal code (in the United States, this is the ZIP code).
- The full name as printed on or associated with a payment instrument such as a credit card. Using a full name field is preferred, typically, over breaking the name into pieces.
- A given (first) name as given on a payment instrument like a credit card.
- A middle name as given on a payment instrument or credit card.
- A family name, as given on a credit card.
- A credit card number or other number identifying a payment method, such as an account number.
- A payment method expiration date, typically in the form "MM/YY" or "MM/YYYY".
- The month in which the payment method expires.
- The year in which the payment method expires.
- The security code for the payment instrument; on credit cards, this is the 3-digit verification number on the back of the card.
- The type of payment instrument (such as "Visa" or "Master Card").
- The currency in which the transaction is to take place.
- The amount, given in the currency specified by
"transaction-currency", of the transaction, for a payment form.
- A preferred language, given as a valid BCP 47 language tag.
- A birth date, as a full date.
- The day of the month of a birth date.
- The month of the year of a birth date.
- The year of a birth date.
- A gender identity (such as "Female", "Fa'afafine", "Male"), as freeform text without newlines.
- A full telephone number, including the country code. If you need to break the phone number up into its components, you can use these values for those fields:
- The country code, such as "1" for the United States, Canada, and other areas in North America and parts of the Caribbean.
- The entire phone number without the country code component, including a country-internal prefix. For the phone number "1-855-555-6502", this field's value would be "855-555-6502".
- The area code, with any country-internal prefix applied if appropriate.
- The phone number without the country or area code. This can be split further into two parts, for phone numbers which have an exchange number and then a number within the exchange. For the phone number "555-6502", use
"tel-local-prefix"for "555" and
- A telephone extension code within the phone number, such as a room or suite number in a hotel or an office extension in a company.
- A URL for an instant messaging protocol endpoint, such as "xmpp:email@example.com".
- A URL, such as a home page or company web site address as appropriate given the context of the other fields in the form.
- The URL of an image representing the person, company, or contact information given in the other fields in the form.
See the WHATWG Standard for more detailed information.
autocomplete attribute also controls whether Firefox will — unlike other browsers — persist the dynamic disabled state and (if applicable) dynamic checkedness of an
<input> across page loads. The persistence feature is enabled by default. Setting the value of the
autocomplete attribute to
off disables this feature. This works even when the
autocomplete attribute would normally not apply to the
<input> by virtue of its
type. See error 654072.
The four administrative level fields (
"address-level4") describe the address in terms of increasing levels of precision within the country in which the address is located. Each country has its own system of administrative levels, and may arrange the levels in different orders when addresses are written.
"address-level1" always represents the broadest administrative division; it is the least-specific portion of the address short of the country name.
Given that different countries write their address in different ways, with each field in different places within the address, and even different sets and numbers of fields entirely, it can be helpful if, when possible, your site is able to switch to the layout expected by your users when presenting an address entry form, given the country the address is located within.
The way each administrative level is used will vary from country to country. Below are some examples; this is not meant to be an exhaustive list.
A typical home address within the United States looks like this:
432 Anywhere St
Exampleville CA 95555
In the United States, the least-specific portion of the address is the state, in this case "CA" (the official US Postal Service shorthand for "California"). Thus
"address-level1" is the state, or "CA" in this case.
The second-least specific portion of the address is the city or town name, so
"address-level2" is "Exampleville" in this example address.
United States addresses do not use levels 3 and up.
The UK uses one or two address levels, depending on the address. These are the post town and, in some instances, the locality.
China can use as many as three administrative levels: the province, the city, and the district.