You are here: Reference > JavaScript > client-side > HTML DOM > properties > autocomplete (form, input)

autocomplete property (form, input)

Browser support:
Sets or retrieves whether the text field should give the user some suggestion during typing.
When the Autocomplete is enabled, suggestions can be visible for the value of the text field. The suggestions are stored on the local machine when the user submits the form, based on the value of the name or vcard_name (Internet Explorer only) property of the element.
You can set the default state of auto completion in a form with the autocomplete property of the form tag. This setting affects all input:password and input:text elements on the form, but can be overridden with the autocomplete property of these tags.
The user can disable Autocomplete windows in Internet Explorer (Tools / Internet Options / Content / Autocomplete - Settings).
The autocomplete property has effect only if the use of Autocomplete windows is enabled in the browser.

Syntax:

object.autocomplete;
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: autoComplete

Possible values:

String that sets or retrieves the state of autocompletion.
One of the following values:
off
AutoComplete is disabled.
on
AutoComplete is enabled.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the autoComplete attribute. The default Autocomplete settings need to be changed for this example in Internet Explorer 8 (Tools / Internet Options / Content / Autocomplete - Settings / enable Forms):
Fill the user name and city fields with some text content, and submit the form.<br />
After that, start to fill these fields with the same content. An autocomplete window will displayed for to the user name field.
<br /><br />
<form method="post">
    User name, with autocompletion:
    <input type="text" name="username" autocomplete="on" />
    <br />
    City, without autocompletion:
    <input type="text" name="city" autocomplete="off" />
    
    <br /><br />
    <input type="submit" value="Send" />
</form>
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the autocomplete property. The default Autocomplete settings need to be changed for this example in Internet Explorer 8 (Tools / Internet Options / Content / Autocomplete - Settings / enable Forms):
<head>
    <script type="text/javascript">
        function DisableAutoComp () {
            var username = document.getElementById ("username");
            if ('autocomplete' in username) {
                username.autocomplete = "off";
            }
            else {
                    // Firefox
                username.setAttribute ("autocomplete", "off");
            }
        }
    </script>
</head>
<body>
    Fill the user name and city fields with some text content, and submit the form.<br />
    After that, start to fill these fields with the same content. An autocomplete window will displayed for to the user name field.
    <br /><br />
    <form method="post" action="#URL#">
        User name, with autocompletion:
        <input type="text" id="username" name="username" autocomplete="on" />
        <br />
        City, without autocompletion:
        <input type="text" name="city" autocomplete="off" />
        
        <br /><br />
        <input type="submit" value="Send" />
    </form>
    <br />
    <button onclick="DisableAutoComp ();">Disable autocompletion!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

External links:

User Contributed Comments

Post Content

Post Content