Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery default value in password field

I am using this Jquery plugin for populating inputs with text that disappears on click. It isn't ideal for password fields because everything shows up as dots. What would be a good way to make a default text visible in password fields before you start typing?

like image 494
CyberJunkie Avatar asked Apr 25 '26 19:04

CyberJunkie


2 Answers

Through JS, my answer would be the same as @ultimatebuster's. However, the whole JS route is hacky, now that alternatives started appearing. Many modern browsers now support this thing directly through HTML5:

<input type="password" name="password" placeholder="Enter password"/>

(Many modern browsers = every major one except the Internet Explorer. I refuse to code for it; if you have to have the same thing in IE as well, you'll have to go the hacky route.)

like image 72
Amadan Avatar answered Apr 27 '26 07:04

Amadan


You could set the type of the input field as password. However, set it to normal via javascript upon page load (this way you can fallback easily if the user doesn't have JS). Once it receives a click, set the type of the input field back to a password.

like image 25
Pwnna Avatar answered Apr 27 '26 08:04

Pwnna



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!