Last active
December 17, 2015 00:29
-
-
Save delba/5521562 to your computer and use it in GitHub Desktop.
Show password checkbox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <%= 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 %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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