Saved Safari passwords override autocomplete = "off" in forms

I have done a lot of research on this, but I can not find anything that solves my problem.

I have autocomplete = "off" set in the form tag and all my input tags, but Safari continues to enter the automatically saved passwords into my form when the page loads, which causes an unwanted keydown event in the form in my JavaScript.

Any thoughts? I tried all kinds of hacks, such as completely removing these input fields from the code, and then using javascript and setTimeout to insert them into the page after a few seconds, but even after that Safari still throws the saved passwords to my inputs,

I also tried using the autocorrect = "off" and autocapitalize = "off" attributes in my and tags.

I tried Javascript hacks like this (example):

$(function() { $('input').attr('autocomplete', 'off'); }); 

So every input field on the page at startup has this attribute, and yet Safari still inserts the saved passwords into the fields.

Yes, the page uses html5 doctype (because I know that autocomplete would not work without it).

Here is my code:

  - form_for @website, :html => {:class => 'fields', :autocomplete => 'off'}, :url => {:controller => 'signup', :action => 'connect'} do |form| %h3 Enter URL %ol.fields %li = form.label :url, "Website URL:" = form.text_field :url, :placeholder => "Website URL", :autocomplete => "off", :class => "website_url" %h3 Enter Credentials - form.fields_for :authentication do |aa| %ol.fields %li = aa.label :hostname, "SFTP/FTP Server:" = aa.text_field :hostname, :placeholder => "SFTP", :autocomplete => "off" %li = aa.label :account, "Username:" = aa.text_field :account, :placeholder => 'Username', :autocomplete => "off" %li = aa.label :password, "Password:" = aa.password_field :password, :placeholder => 'Password', :autocomplete => "off" 

The foregoing in haml. This is a ruby โ€‹โ€‹app. It inserts my passwords into the input: account and password entry :. I tried wrapping part of the name "my": the login for the account in span tags as follows:

 User<span>n</span>ame 

due to the fact that the word "name" is a trigger for autosaved passwords, but safari still throws the saved passwords into my form after this attempt to resolve this issue.

I would really appreciate some new tips that I could try. All that I have found so far for this problem, people just say "use autocomplete =" off. "I am, but it does not work!

In addition, I tested this with Safari 6.1.2, but confirmed this strange behavior with both old and new versions of Safari. A link to a screenshot of the browser overview, so I know that the autocomplete = "off" attribute is added to the elements: http://imgur.com/Sgqn7A4

+6
source share
4 answers

It seems that Safari and others have decided to stop executing this attribute.

https://discussions.apple.com/message/25149138#25149138

http://blog.gerv.net/2013/10/ie-11-ignoring-autocompleteoff

 // Override Safari, Chrome and IE11 decision to ignore autocomplete: off // on form you wish to skip autocomplete, change all password fields to type=private // requires jQuery $(function() { $('input[type="private"]').focus(function(e){ $(this).prop('type', 'password'); }); $('input[type="private"]').parents('form').submit(function(){ $(this).find('input[type="password"]').hide().prop('type', 'private'); }); }); 
+6
source
Decision

@t_itchy does not work in Firefox because it initially prevents the entry of a value, but as soon as you give the focus of the password field, a password is added to it. The following solution has been edited using it and controls the maxlength property to prevent the presence of a password. In addition, since Firefox behaves strangely when a password field is eroded, it also discards the password field for private blurring if it is empty.

 // Override Safari, Chrome and IE11 decision to ignore autocomplete: off // on form you wish to skip autocomplete, change all password fields to type=private // requires jQuery // External function for removing maxlength restriction - apparently required function removemaxlength(me) { window.setTimeout(function() {me.prop('maxlength',100)},100); } $(function() { $('input[type="private"]').focus(function(e){ $(this).prop('maxlength',0).prop('type', 'password'); removemaxlength($(this)); }).blur(function(e){ // When leaving an empty field ONLY, revert to private if (!$(this).val()) $(this).prop('type', 'private'); }); // This appears unnecessary, left as comment for completeness // $('input[type="private"]').parents('form').submit(function(){ // $(this).find('input[type="password"]').hide().prop('type', 'private'); // }); }); 
0
source

Mac Safari does not respect autocomplete = "off" in tags. He searches for a combination of email and password and automatically fills them out.

Since I had the same problem when I have two fields.

 <input type="text" name="email" id="email" value="" placeholder="Enter Email"> <input type="password" name="password" id="password" value="" placeholder="Enter Password"> 

Since safari is looking for a combination of text and password in this case, to autocomplete fields with values โ€‹โ€‹stored in browser cookies.

You just need to do two things.

 <input type="password" name="email" id="email" value="" placeholder="Enter Email" onfocus="this.type='text'"> 
  • Change the email field type to password instead of text when loading a form or loading a page.
  • For the onfocus event with a javascript type change for the field that is required for the text.

This is just a hack. If anyone else has a better solution, send a message.

0
source

Safari already saved the data. After the browser has saved the data, autocomplte = "off" does not actually work. Perhaps you can go to preference => AutoFill => Change (username and password) and delete what you already placed there, and try again.

Hope this helps :)

-1
source

All Articles