Skip to content

Instantly share code, notes, and snippets.

@delba
Last active December 17, 2015 00:29
Show Gist options
  • Select an option

  • Save delba/5521562 to your computer and use it in GitHub Desktop.

Select an option

Save delba/5521562 to your computer and use it in GitHub Desktop.
Show password checkbox
<%= form_for @user, url: :signup do |f| %>
<%= f.label :email %>
<%= f.email_field :email %>
<%= f.label :password %>
<%= f.password_field :password, autocomplete: 'off' %>
<input type="checkbox" id="show_password" />
<label for="show_password">Show Password</label>
<%= f.submit "Sign Up" %>
<% end %>
show_password.addEventListener 'change', ->
user_password.type = if @checked then 'text' else 'password'
# Notes:
# - Rails filters password parameter (Rails.application.config.filter_parameters)
# - Disable the password field autocompletion!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment