I have a input type text
for user to change their email & password in account setting page.
How can stop Chrome auto fill the input.
Chrome remember the input data
from log in page and it auto fill in account setting page.
Chrome auto fill the input
change my email & password in account setting page
Add autocomplete="off" onto <form> element; Add hidden <input> with autocomplete="false" as a first children element of the form.
We are no longer dependent on hacks for this. You can set autocomplete to new-password and it will work as intended.
<input type="password" name="pwd" autocomplete="new-password">
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-autocomplete
Are you explicitly setting the values as blank? For example:
<input type="text" name="textfield" value="">
That should stop browsers putting data in where it shouldn't. Alternatively, you can add the autocomplete attribute to the form tag:
<form autocomplete="off" ...></form>
Solution 1:
Putting 2 lines of code under under <form ..>
tag does the trick.
<form id="form1" runat="server" >
<input style="display:none" type="text" name="fakeusernameremembered"/>
<input style="display:none" type="password" name="fakepasswordremembered"/>
...
Read more
Solution 2: It removes "name" and "id" attributes from elements and assigns them back after 1ms. Put this in document get ready.
$('form[autocomplete="off"] input, input[autocomplete="off"]').each(function () {
var input = this;
var name = $(input).attr('name');
var id = $(input).attr('id');
$(input).removeAttr('name');
$(input).removeAttr('id');
setTimeout(function () {
$(input).attr('name', name);
$(input).attr('id', id);
}, 1);
});
Solution 3: Tested in Chrome 60.0.3112.101
<input type="password" name="pwd" autocomplete="new-password">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With