0

I haven't set the form input default value, however I eveytime access the page, the form input text has default value. This situation happens in Google chrome, After I set autocomplete="off" in the input and form element. Firefox is ok now but Chrome is still displaying a default value.

This is my html code:

<form id="add-host-form" class="form-inline">
  <div class="form-group">
    <label for="ip-addr">IP</label>
    <input class="form-control" type="text" id="ip-addr">
  </div>
  <div class="form-group">
    <label for="passwd">Passwd</label>
    <input class="form-control" type="password" id="passwd">
  </div>
  <button type="submit" class="btn btn-primary">Submit</button>
</form>

Every time I access the page, I got: I don't know where is the default value come and how to disable it? enter image description here

zJorge
  • 746
  • 2
  • 12
  • 24
buweilv
  • 341
  • 3
  • 17

3 Answers3

1

These values are auto filled by browser that it had saved earlier.

You can clear your browser cache, stored passwords and saved form data to keep this from happening.

Andrew Li
  • 47,104
  • 10
  • 106
  • 132
Ambrish Pathak
  • 3,408
  • 1
  • 13
  • 28
  • My browser is google chrome, and I have use **Clear browsing data**, and I select [Browsing history cookies] [other site and plugin data] [cached images and files] and [Autofill form data selctions], it doesn't matter. – buweilv Dec 23 '16 at 04:55
0

The auto-suggest/auto-complete is done by the browser based on your previous activities. To not have the browser do it . Set the element autocomolete property to off

<input class="form-control" type="text" id="ip-addr" autocomplete="off" />

Rajshekar Reddy
  • 17,202
  • 3
  • 34
  • 54
  • I'm sorry to find that even I added **autocomplete="off"**, there still exists these default values – buweilv Dec 23 '16 at 05:10
0

Browsers autofill the form from the stored user id and password.

<input class="form-control" type="text" id="ip-addr" autocomplete="off" />

The above may work in some browsers. However to support most of the browsers, the autocomplete="off" must be added in the form tag.

<form autocomplete="off">
    <input class="form-control" type="text" id="ip-addr" />
</form>

You can have a look at this for autocomplete support in chrome https://bugs.chromium.org/p/chromium/issues/detail?id=468153#c164

Jones Joseph
  • 3,856
  • 1
  • 19
  • 37