Javascript - 在 JS 警报框上隐藏密码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5131785/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Javascript - Masking a password on a JS alert box
提问by Cecil
I have the following
我有以下
var validate=prompt("Enter your PIN","Enter your PIN");
This works fine except it shows the password when typing it.
这工作正常,只是它在键入时显示密码。
Is there any way to mask the password being entered?
有没有办法屏蔽输入的密码?
Cheers,
干杯,
回答by Sarfraz
Nope, there is no way to mask promptbox. You will have to use some other custom solutionor use passwordinput box instead.
不,没有办法屏蔽prompt盒子。您将不得不使用其他一些自定义解决方案或使用password输入框。
If you want to do validation of password, do it on the server-side not client-side.
如果要验证密码,请在服务器端而不是客户端进行验证。
回答by amitchd
If you really want a prompt window and accept a password, you might want to use this plugin along with jquery. Check out example 9 on http://trentrichardson.com/Impromptu/index.phpand use type="password"instead.
如果您真的想要一个提示窗口并接受密码,您可能希望将此插件与 jquery 一起使用。查看http://trentrichardson.com/Impromptu/index.php上的示例 9并type="password"改用。
回答by pohchen
It's impossible to hide the password.JS load on the client side. We can easily find the password by checking the source code.
在客户端隐藏 password.JS 负载是不可能的。我们可以通过查看源代码轻松找到密码。
Here is an example. Check it out yourself http://www.pageresource.com/jscript/jpass.htm
这是一个例子。自己检查一下 http://www.pageresource.com/jscript/jpass.htm

