Input autocomplete off не работает

Как отключить автозаполнение форм с помощью html 5?

Собственно сабж.
Пробовал так:

Ничего не получается. На поле всё равно срабатывает авто заполнение.
Что я делаю не так?

UPD.

  • Вопрос задан более трёх лет назад
  • 44197 просмотров

14.10.2021. Chrome Версия 94.0.4606.81 (Официальная сборка), (64 бит) до сих пор работает)

Очень простой и изящный способ как отключить автозаполнения и выпадающие списки с выбором логина и пароля от браузера на формах регистрации и прочих формах.

здесь мы отключаем автозаполнение пароля, а также чтобы не было выпадающего списка выбором паролей там где это не нужно:
— оборачиваем форму в блок со свойством position:relative
— после поля прописываем блок с position:absolute top:0 left:0 width:100% height:100%
— создаем событие onclick, для класса field где вызываем фокус для нашего поля внутри

разница на скриншотах

До

После

Можно отключить автозаполнение, если в момент фокусировки в поле поменять у поля значение name на произвольное. А когда пользователь выходит из input, то поменять значение name обратно. В этом случае браузер Хром не выводит подсказок, т.к. каждый раз значение name новое.
Необходимо подключать jquery, а ниже подключить сам скрипт.

Исходник (взял отсюда только код, который генерит значение name) https://github.com/terrylinooo/jquery.disableAutoFill

Что получилось в итоге:

Это сама форма, показываю кусок формы, с полями ввода, для которых отключаю подсказки хрома. Оба инпута имеют класс «only-ru»:

Сам скрипт, который при фокусе генерит произвольное значение для name, а при выходе из фокуса — возвращает значение name обратно, как мне нужно. Можете его улучить, сделать более универсальным:

в хроме и файрфоксе работает. в сафари ещё не проверял — нет под рукой.

я в vue шаблонах так сделал:

никакого jquery конечно же. всё уже работает.
focusCounter само собой в дате объявить. можно один на все инпуты формы

Источник

autocomplete =’off’ is not working when the input type is password and make the input field above it to enable autocomplete

I have an form with autocomplete disabled but it does not works and makes the autocomplete to be enabled in firefox and higher version of chrome

When the type is changed from password to text it works in all browser. Can anyone help to solve this issue?

28 Answers 28

You can just make the field readonly while form loading. While the field get focus you can change that field to be editable. This is simplest way to avoid auto complete.

When I faced the same problem I resolved by creating a temporary text box above the password field and hide it

It will make the username text field not to show any previously typed words in a drop down. Since there is no attribute like name , id for the input field it wouldn’t send any extra parameters also.

I am Not sure this is a good practice, but it will resolve the issue.

This will prevent the auto-filling of password into the input field’s (type=»password»).

Читайте также:  Нет подключения роутера как настроить

Browser’s normally have two related yet different features regarding forms:

Form auto-complete, where items of type (and similar) collect typed values and offer them back in the form of a drop-down list.
(It’s a simple feature that works pretty well.)

Password manager, where browser prompts to remember username/password combinations when it detects you’ve submitted a login form. When returning to the site, most browsers display available usernames in a drop-down box (Firefox, Chrome, Internet Explorer. ) but some have a toolbar button (Opera). Also, Chrome highlights the fields in hard-coded yellow.
(This depends on heuristics and might fail on certain pages.)

There’s an edge case with forms tagged as autocomplete=»off» . What happens if it’s a login form and the user has previously stored a username/password? Actually removing the password from the local database looks like inappropriate so probably no browser does so. (In fact, data from form auto-complete is not erased either.) Firefox decides to give power to the user: you have a password, so I’ll let you use it. Chrome decides to give power to the site.

Источник

autocomplete = ‘off’ is not working on firefox

I created 2 login pages of same domain.

I put the form name different for 2 forms with in these two page. Also I put autocomplete = ‘off’ for the second form and for the text fields within that form.(But it is on for first form ).

Now if I save the username and password at the time of login from www.testDomain.com/login.cfm in browser, then the list of usernames are auto populating in the username field of second login page even if the auto Complete is off. I need to block this for security reasons. Is there any way to do this? I am using FireFox V21.

17 Answers 17

This is the cleanest solution I have found to keep Firefox from auto completing.

Add this code snip-it above your input of type password.

As far as I can tell Firefox is looking for an input of type Password, and filling in the password and then adding the username to the input of type text above it. Without a name or an id the inputs don’t get added to the post, but this is still a hack.

You all should try this attribute :

Firefox version 61 this seems to be enough to disable autocomplete in forms:

All inputs after this one at the top of the form are ignored.

This is working for me:

Click here for more info about this.

I was encountered this issue for a long time. Firefox was kept input values even page reload. Setting autocomplete attribute to off did not solve.

Form caching is a really useful mechanism for the user experience. But, in the small percentage of use-cases like translating values of textboxes or texareas to other language, these gave me headache.

To resolve this, just simply reset the form after page was loaded as

Nothing worked for me for the password field so I’ll share my trick

I believe it is still secure and works on Chrome, Firefox, other

I’ve noticed this behavior also lately — Firefox only; there’s seems to be a problem with the ‘autocomplete=»off»‘ attribute.

Used to work great up until a month ago — and broke up around the time Firefox version 30.0 was released.

Still works great on Chrome + IE;

Autocomplete has been disabled for password type input fields. The above links mention that respectively for FireFox and IE, but I see that setting autocomplete to off for form too is not working.

Читайте также:  Почему не работает контроллер ps4

Type must be the same. The hidden password will be fill instead of real password input.

If it’s a new password (or reseted) use autocomplete=»new-password» instead of autocomplete=»off».

I tried all of the above with Firefox 52 and nothing worked. I did get it to work with jQuery though and replacing the value with the original value, or:

where in jQuery the prop is the current value in the document and attr is the original when the document is first retrieved/loaded. I used the load function because it runs after the ready function and I believe definitely after the autocomplete overwrites the input value. you can do the same thing with the password input also.

A way to Firefox don’t find those fields is to change their type to hidden before the post.

You can use a jQuery or JavaScript to set that on onclientclick in your submit button.

Just remember to clear your browser’s cache before testing or use the private mode (CTRL+SHIFT+P).

thanks to the idea of albert.garipov, i made a solution that mimics the functionality of the type password. this doesn’t show the password on input

Just put a random value in autocomplete.

Use autocomplete=»off» tag at the end of your input tag:

I realize that this is an old question, but as it’s still relevant on Google searches, I believe it’s important to present another view which opposes a lot of the answers here which, while well intentioned, are somewhat short-sighted.

Preventing auto-fill for login inputs can lead to a lot of problems. There are no benefits and significant downsides. Humans are bad at remembering credentials, leading to people without password managers using the same passwords on multiple (often critical) sites. If one of these sites is compromised, there’s a very good chance that an attacker can log into other sites with the same credentials. Tools like LastPass, Bitwarden, Dashlane, Onepassword, etc. all exist for a good reason: they help keep the web a safer place for the majority of users by facilitating the use of separate passwords per web site.

Mozilla, Google and Microsoft are all on-board with this and have purposely decided to ignore the autocomplete=»off» directive in many cases where it is likely to be more beneficial, in the long run. For further details about this, I’d recommend taking a look at the following articles from Mozilla, Google/Chromium, Microsoft and the Web Hypertext Application Technology Working Group:

Now, there may be cases where you’re writing an internal application in an industry with strict compliance requirements. It might seem like a good idea to disable auto-fill for login forms in this environment given the added potential for sharing passwords if left alone. My answer to that would be that this is out of scope for the front-end web developer, and should fall to the desktop experience and the IT operations teams.

There are many ways that IT departments can enforce controls on workstations to prevent automated password sharing. Group Policy, SCCM, least-privilege account provisioning, etc. are all just the tip of the iceberg, and they’ve far more robust than attempting to tell the user-agent to disable autocomplete when it’s not designed to function that way.

tl;dr: Please take the time to understand the platform you’re developing for and don’t work around the specs to disable autocomplete.

Источник

autocomplete=»off» does not work in chrome #247

Comments

sdwvit commented Aug 16, 2018 •

Expected behaviour: chrome native autocomplete is not drawn on top of autocomplete.js autocomplete.

Читайте также:  Как настроить телефонию манго

  • use autocomplete=»new-password»
  • insert input right before your autocompleted input

The text was updated successfully, but these errors were encountered:

Haroenv commented Aug 17, 2018

hmm, this doesn’t happen to me on busbud, did you fix it there? This definitely seems like a nasty bug in Chrome. Maybe it has something to do with having autofill enabled on that website before?

Could you share a bit more in which setup is necessary for this to happen?

Haroenv commented Aug 17, 2018

Note that the off value is the one that makes it work in FF and Safari, so I fear it will be hard to value both of those requirements

sdwvit commented Aug 17, 2018 •

@Haroenv yes, fixed yesterday with one of the workarounds, specifically, by adding additional hidden input

Maybe it has something to do with having autofill enabled on that website before?

exactly, you have to be returning user, which uses our search form multiple times

see video of repro:

Unfortunately, I have no right to setup preview env for you to see bug on busbud in action. Let me know if video is unclear.

Haroenv commented Aug 17, 2018

Thanks for your detailed bug report by the way, we will try to see if we can find a solution. It might be quite simple to implement here since we already have two inputs. It would be really nice if you already have to solution to take a look if you can do a PR 😄

sdwvit commented Aug 17, 2018

Can’t promise, but will try to find time to do a pr on weekends.

Haroenv commented Aug 18, 2018

Cool! If you don’t find time to do a PR, a clear suggestion on which attribute to change where would also be sufficient, it’s still pretty confusing what to put where 🙂

Источник

Chrome игнорирует autocomplete = «off» [дубликаты]

Я создал веб-приложение, в котором используется тегбокс. Это отлично работает во всех браузерах, кроме браузера Chrome (версия 21.0.1180.89).

Несмотря на то, что оба поля input и поле form имеют атрибут autocomplete=»off» , Chrome настаивает на том, чтобы отобразить раскрывающийся список предыдущих записей для поля, который стирает список тегов.

45 ответов

ОБНОВИТЬ

Теперь Chrome игнорирует style=»display: none;» или style=»visibility: hidden; атрибуты.

Вы можете изменить его на что-то вроде:

По моему опыту, Chrome только автозаполняет первый и предыдущий . Поэтому я добавил:

JS (onload):

или с помощью jQuery:

Чтобы добавить несколько полей с помощью jQuery:

Работает в:

Похоже, Chrome теперь игнорирует autocomplete=»off» , если он не находится в теге

Хорошей новостью является то, что, поскольку «подпись формы» повреждена этим, ни одно из полей не автозаполняется, поэтому для очистки фальшивых полей перед отправкой не требуется JS.

Старый ответ:

Единственное, что, по моему мнению, по-прежнему жизнеспособно, — вставить два фиктивных поля типа email и password перед реальными полями. Вы можете установить их в display: none , чтобы скрыть их (это недостаточно умно, чтобы игнорировать эти поля):

К сожалению, поля должны быть в вашей форме (в противном случае оба набора входов автозаполняются). Итак, для того, чтобы фальшивые поля были действительно проигнорированы, вам понадобится JS для запуска в форме submit, чтобы очистить их:

Обратите внимание, что очистка значения с помощью Javascript позволяет переопределить автозаполнение. Поэтому, если допустимо нарушение правильного поведения с отключенным JS, вы можете упростить все это с помощью автозаполнения JS «polyfill» для Chrome:

Источник

Оцените статью