Question

I have a basic JS code for a password, but whenever I type into the text box, it shows what has been typed, not the normal asterisks that are shown in password boxes. My code follows.

<!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>

Note: I made this for fun, I'm not stupid enough to use it for real protection.

Was it helpful?

Solution 2

You can't do that in a prompt. A prompt is a feature of the browser / OS that is sandboxed. If you want control you need to do it in HTML:

<input type="password" />

OTHER TIPS

You should use: <input type="password">.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top