Questions
Questions

Reputation: 20875

How to disable to autocomplete by HTML code?

I want to ask a question about the html code. I have a input type="text". And I have added the auto-complete function in the text box (like the google suggestion list). However, when I click the text and start the to type the text, it display 2 auto-complete function.

  1. browser e.g. like you type your account in the browser to login somewhere, and other time you go the text, it will appear to you for you to select.

  2. my implementation of the auto-complete function.

I want to disable the 1. and keep the 2. Is it possible to do that by using web programming rather than set the browser setting. thank you.

Upvotes: 1

Views: 1167

Answers (2)

Rohit Suthar
Rohit Suthar

Reputation: 3628

By Using Jquery (W3C Valid)

//Try this one:

    $(document).ready(function(){
    $("input.autocompleteOff").attr("autocomplete","off");
    });

//For all textbox -

    $(document).ready(function(){$("input").attr("autocomplete","off");});

//HTML

<input type="text" name="field" id="field" class="autocompleteOff" />

Upvotes: 0

Pekka
Pekka

Reputation: 449385

In addition to the (Unfortunately not W3C valid) autocomplete="off" method mentioned in the duplicate link, a server-side possibility to do this is to change the field's ID and name on every request. This will make it impossible for the browser to keep a history.

However, that will probably still show autocomplete entries from just a second ago.

Upvotes: 3

Related Questions