使用 JavaScript 显示和隐藏密码
在填写表格时,会出现我们输入密码并想查看到目前为止我们输入了什么的情况。要看到这一点,请单击一个复选框,使字符可见。
在这篇文章中,此功能(即切换密码)是使用 JavaScript 实现的。
Algorithm
1)Create a HTML form which contain an input field of type password.
2)Create a checkbox which will be responsible for toggling.
3)Create a function which will response for toggling when a user clicks on the checkbox.
例子:
Password is geeksforgeeks.
So, on typing it will show like this *************
And on clicking the checkbox it will show the characters: geeksforgeeks.
Click on the checkbox to show
or hide password:
Password:
Show Password
输出:
- 隐藏密码:
- 显示密码: