I would like the admin user of my app to be able to invite new users.
The flow is:
- admin user input new user name and email
- generate a random password for the new user
- display name, email and password for review
- admin user click a button, and ajax sends name, email and password to server
- server create new user
The rest is easy, except for step 3.
What I want is something like: <p>{password}</p>
, and it will be displayed as ******
for default.
If admin user want to see the password, click some button and the password will show as normal text.
I know how to do this with <input>
, but is it possible without using <input>
?
My current solution is managing a show
state for the <p>
with javascript, if show === false
, display <p>********</p>
, else display <p>{password}</p>
.
But I'd be happy to see a simpler solution without javascript.
UPDATE
A slightly different solution based on this; password keeps showing even when mouse moved away.
Any element with a tabindex
could be focused
p {
position: relative;
width: 100px;
}
p:after{
content: '*****';
position: absolute;
background-color: white;
right: 0;
left: 0;
top:0;
}
p:focus:after{
content: ''
}
<p tabindex="-1">password1</p>
<p tabindex="-1">password2</p>