Repository is archived
No commit activity in last 3 years
No release in over 3 years
Fix autofilling password fields in Safari.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

FakePasswordField

Prevents Safari from autofilling password fields you don't want autofilled. See http://stackoverflow.com/questions/22817801/how-to-disable-auto-fill-in-safari-7 for a good explanation of the bug.

Tested on Rails 4. (Probably works on other versions too, if anyone is keen to test & update the gem's dependencies.)

Installing

Add this line to your application's Gemfile:

gem 'fake_password_field'

And then execute:

$ bundle

Or install it yourself as:

$ gem install fake_password_field

Available on RubyGems: https://rubygems.org/gems/fake_password_field

Usage

Add a fake_password_field_tag to the top of your page. Or if you're using a FormBuilder (form_for(@object)...), add a f.fake_password_field.

How it works

This inserts a dummy HTML password element, which is hidden from view and will not be posted. But it will trick Safari into not autofilling your actual password field.

You should experiment with the best place in the form to add this element. Usually adding it to the top works well, but some form layouts work best if it's added to the bottom.

The HTML looks like this:

<div class="break_safari_autofill" style="left: -9999px; position: fixed; width: 1px;"><input type="password"></div> <!-- http://stackoverflow.com/a/24471266/641293 -->