我有一个基本的密码 JS 代码,但是每当我在文本框中键入内容时,它都会显示已键入的内容,而不是密码框中显示的普通星号。我的代码如下。
<!DOCTYPE html>
<html>
<title>
Enter Password
</title>
<body>
<script type="text/javascript">
var password = "THE LIST";
var x = prompt("Enter in the password "," ");
if (x == password) {
window.location = "index.html";
}
else {
window.location = "bad.htm";
}
</script>
</body>
</html>
注意:我做这个是为了好玩,我还没有愚蠢到用它来实现真正的保护。
最佳答案
您应该使用:<input type="password">
.
关于javascript - 如何将 .js 密码设置为星号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21198864/