In Ruby on Rails, I have the line
<td><%= text_field_tag(:email, "email") %></td>
which places the word "e-mail" in the box where e-mail is supposed to go. This is exactly what I want, as it saves space. However, when I do this:
<td><%= password_field_tag(:password, "password") %></td>
The text is just a bunch of dots. I want the text to say password, but when the user fills it in I want dots to appear. Facebook does exactly what I want here https://www.facebook.com.
Could someone please tell me how to accomplish writing the word "password" visibly in the password field box yet having the password appear dotted-out when the user actually goes to fill it in?
You need to set the placeholder attribute, not the value attribute:
<td><%= password_field_tag(:password, "", placeholder: "Password") %></td>
You should do the same thing for your email field. Don't set the value of the element, set a placeholder and let the browser render it specifically as a placeholder.
The actual textual value of the password field will always render as dots or asterisks, regardless of whether you set it via script or the user types it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With