Good day all,
I have a form that has a password field:
<input type="password" name="password" size="30" />
Naturally, the input text will be replaced by (*).
So if the user typed 123
the box will show ***
.
Up to here, it is straight forward, but...
Now, I wanna add a small icon next to the password box so when the user hover over this icon, he can see what he has entered so far.
So, while hovering, the box will show 123
and when the user leaves the icon the box should show ***
again.
Is there any way to do this with JavaScript? Also, I am using HTML and PHP.
EDIT:
It really doesn't need to be an icon, it could be a checkbox or a button... AND if it could be done in CSS, I would really appreciate to know how
P.S. I've googled and search the stackoverflow but with no luck
Try this see if it works
You will need to get the textbox via javascript when moving the mouse over it and change its
type
totext
. And when moving it out, you will want to change it back topassword
. No chance of doing this in pure CSS.HTML:
JS:
In one line of code as below :
As these guys said, just change input type.
But do not forget to change type back as well.
See my simple jquery demo: http://jsfiddle.net/kPJbU/1/
HTML:
jQuery:
Complete example below. I just love the copy/paste :)
HTML
CSS
JS
Try it here: https://codepen.io/anon/pen/ZoMQZP
I use this one line of code, it should do it: