Pro-tip for form autocompletion

Have you ever been editing a user record in your CMS and tried to save the form, only to get an error that the passwords don’t match even though you didn’t try to update the password? I have. And it’s annoying. Very annoying.

Here’s a little tip to help resolve that issue. When creating a form for managing users, make sure to disable the autocomplete functionality so that your browser doesn’t fill the form out with your own user account information. To do this, all you need to do is add an ‘autocomplete’ attribute to your form and set it to off like so

autocomplete=”off”

In rails, it will look like

<%= form_for [:admin, @user], :html => { :autocomplete => :off } do |f| %>

Alternatively, you can add it directly to a form field.  In ASP.NET MVC, it would like like this:

<%= Html.PasswordFor(model => model.Password, new { autocomplete = “off” })%>

 

Comments are closed.