Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

autocomplete= off not working in chrome

We are working on one web application in that one payment page is there.

In that we have two Text box one is for Credit Card Number and second one is for Verification Code and it type="Password".

Now problem is when page is load in google-chrome it found type="Password" it load Save email id in Credit Card Textbox and password in Verification Code.

Now try to solve this issue i was try out something like below.

<form autocomplete="off">

<asp:textbox autocomplete="off">

This above try is not work for me. i was googling it but by luck it's not work for me.

like image 336
Archit Avatar asked Jul 24 '15 14:07

Archit


People also ask

How do I turn off autocomplete in Chrome?

To disable autocomplete on the whole form: <form autocomplete="off" ...> Or if you dynamically need to do it: <form autocomplete="random-string" ...>

Why is autocomplete not working in Chrome?

Enable Autocomplete Step 1: Open Chrome on your PC and click on the three-dot icon at the top-right corner. Select Settings from the menu. Step 2: Click on Sync and Google services under People. Step 3: Turn the toggle on present next to Autocomplete searches and URLs.

Why do browsers ignore autocomplete off?

This is because with HTML, this attribute (like any other), is a suggestion to the browser. To make things a little more complicated, browsers may also autofill form fields based on the field's name or id attributes. This is how browsers did it before the autocomplete attribute came along.

How do I force autocomplete off?

Use the <input> tag with autocomplete attribute. Set the autocomplete attribute to value “off”.


2 Answers

It appears that Chrome now ignores autocomplete="off" unless it is on the <form autocomplete="off"> tag since v34.

you can't cheat by create an hidden input over. Auto complete feature will get the first input text to fill data.

Method 1:

<form id="" method="post" action="" autocomplete="off">
    <input type="text" style="display:none" />
    <input type="password" style="display:none">
    <asp:textbox autocomplete="off">
</form>

So put this before your textbox.

<input type="text" style="display:none" />

Method 2:

Change

autocomplete="off" 

to

autocomplete="false" 

Method 3: Browser autofill in by readonly-mode.

 <input type="password" readonly onfocus="this.removeAttribute('readonly');"/>

Method 4:

For username password combinations. Chrome heuristics looks for the pattern.

<input type="text" onfocus="this.type='password'">

Method 5: jQuery

if ($.browser.webkit) {
    $('input[name="password"]').attr('autocomplete', 'off');
    $('input[name="email"]').attr('autocomplete', 'off');
}
like image 143
Darren Willows Avatar answered Sep 27 '22 23:09

Darren Willows


This is the only solution that worked for me with both Autocomplete and Chrome's Autofill: It works also after calling new this.props.google.maps.places.Autocomplete

  1. Add autocomplete="off" on the form tag.

  2. Set autocomplete="none" directly on the input inside the form and set the attribute again on focus.

     <form autocomplete="off">
         <input type="text" autocomplete="none" onfocus="this.setAttribute('autocomplete', 'none');"/>
     </form>
    
like image 27
Laiacy Avatar answered Sep 28 '22 01:09

Laiacy