javascript 如何在javascript提示框中输入密码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23754317/
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
how to take input as password in javascript promt box
提问by Engineer
i want to take input password in java script prompt box but it only take input as string which is visible now how i can take input password in same text field. is there any way to change this text field from input type text to password without div
我想在java脚本提示框中输入密码,但它只将输入作为字符串输入,现在我可以在同一个文本字段中输入密码。有什么方法可以在没有 div 的情况下将此文本字段从输入类型文本更改为密码
this is what i have already tried
这是我已经尝试过的
prompt("enter password");
here is example
这是例子
can any one suggest me how i can do this using j query or java script
任何人都可以建议我如何使用 j 查询或 java 脚本来做到这一点
回答by rajesh kakawat
回答by Justus Romijn
prompt
is native browser functionality, and therefore not very flexible. Unfortunately, you cannot mask the input from a prompt.
prompt
是本机浏览器功能,因此不是很灵活。不幸的是,您无法屏蔽提示中的输入。
Alternatively, you can use the input element with the password type:
或者,您可以使用带有密码类型的输入元素:
<input type="password" size="25" />
And show this in a custom modal window. An input element with the type="password"
attribute set, will automatically mask the entered characters. On how to embed this in a modal, there are many possibilities. If you are using jQuery, you might want to consider using jQuery UI for this:
http://jqueryui.com/dialog/
并在自定义模式窗口中显示此内容。type="password"
设置了属性的输入元素将自动屏蔽输入的字符。关于如何将其嵌入到模态中,有很多可能性。如果您使用 jQuery,您可能需要考虑为此使用 jQuery UI:http:
//jqueryui.com/dialog/