Turning off auto-complete for text fields in Firefox

Viewed 29480

Am supposed to be learning French at the moment, but rather than learning any vocab, I've been mucking around with a rails app that tests vocab - so it displays a word, and I have to type its translation.

Unfortunately, Firefox remembers everything I've already type there, so which diminishes its usefulness somewhat.

Is it possible, through the options for form_for or otherwise, to turn this normally useful behaviour off?

7 Answers

So it turns out it's pretty simple. Rather than

<%= f.text_field :fieldname %>

put

<%= f.text_field :fieldname, :autocomplete => :off %>

You can also turn off autocomplete at the form level by using the :autocomplete attribute in the :html collection, which will generate the HTML that Erv referenced. The syntax is

<% form_for :form_name, @form_name, :html => {:autocomplete => "off"} do |f|%>
...
<% end %>

Add autocomplete="off" as an attibute on your form tag:

<form action="..." method="..." autocomplete="off" >
</form>

This worked for me in Rails 4+

<%= f.text_field :name, autocomplete: :off %>

Nice and simple

Simple solution for me in Rails 4+

In the form i added:

:autocomplete => "off"

And in the field:

:autocomplete=>"none"

Example:

  <%= form_for(@user.address_detail,
           :url => {:action => :update_address},
           :validate => true,
           :method => :put,
           :html => {:class => "form-horizontal",:autocomplete => "off"},
  ) do |f| %>

          <div class="controls">
        <%= f.text_field :address_line_1,:autocomplete=>"none" %>
      </div>
Related