1

I have a input like this:

<input name="username" placeholder="Email" type="email" autocomplete="off" />

As you see I've set autocomplete attribute to off. But still when I open that page, the previous value is there:

enter image description here

Well how can I avoid that? Actually my problem is with ugly-background-color-input. When I change its value, it looks like this:

enter image description here

Anyway how can I deactivate caching for inputs?

Martin AJ
  • 5,313
  • 4
  • 32
  • 79

4 Answers4

2

try to do following :

<form autocomplete="off" ...></form>

it may work... or you can do this too.

$('#textfield').attr('autocomplete','off');

or use autocomplete="false", instead of autocomplete="off"

yash
  • 1,641
  • 1
  • 20
  • 30
1

As you mentioned in your question that the background color of your input box is your problem, then you can change it the way you want.

You can use:

input:-webkit-autofill {
   -webkit-box-shadow: 0 0 0px 1000px white inset;
}

Which will change the background to white. Or you may change it to any color you like.

John
  • 142
  • 9
0

when it is just about the design try

input:-webkit-autofill {
    transition: background-color 5000s ease-in-out 0s;
}

in your css

Unfortunately Google chrome change it`s autocomplete settings with every new release. When you want to disable them now you have to update your solution everytime to prevent it in further versions

Edit:
The only thing you can do to stop autofill and remembering passwords completely is giving IDs without "name" or "password" in it

Robin Schambach
  • 409
  • 1
  • 11
  • 20
0

Presumably you also a have a password field on the page? If not you can generate a random field name and get the value from the request object's key/value collection (maybe using a known prefix).

After looking at every answer to do with disabling autocomplete and trying around 20 combinations, the following was found to work on all current browsers (including latest Firefox, Chrome, IE 11 & IE Edge)

Place 2 dummy inputs (1 text and 1 password) with no names and no tabbing at the top of your form, but style them to be hidden (e.g. placed offscreen, but not actually display: none)

e.g.

<input tabindex="-1" style="left: -9999px;" type="text">
<input tabindex="-1" style="left: -9999px;" type="password">

Even the smartest browsers, which look for the first password field (regardless of its name) and attach the autocomplete to the previous input, will work with this.

Gone Coding
  • 88,305
  • 23
  • 172
  • 188