Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop Google chrome auto fill the input [duplicate]

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

like image 247
Ben Avatar asked Aug 30 '13 11:08

Ben


People also ask

How do I stop an input field from auto filling?

Add autocomplete="off" onto <form> element; Add hidden <input> with autocomplete="false" as a first children element of the form.


3 Answers

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

like image 149
Peo Bondesson Avatar answered Oct 17 '22 00:10

Peo Bondesson


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>
like image 24
Roy M J Avatar answered Oct 17 '22 02:10

Roy M J


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">
like image 21
Sangram Nandkhile Avatar answered Oct 17 '22 02:10

Sangram Nandkhile