Web Development

General discussion


Hide/mask JavaScript password

By kent2612 ·
how do i hide the password
when it is input via the prompt dialogue. So as not to allow others around
to see the password.

<script language="Javascript">


var password = "please"

var x = prompt("Enter in the password"," ")

if (x.toLowerCase() == password) {
alert("Come right in \n \n You've entered in the right password")
location = "right.html"

else {
location = "wrong.html"


This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by nikki96 In reply to Hide/mask JavaScript pass ...

You don't. Anyone can look at client side text. You can obfuscate it, but anyone can just deobfuscate it.
Javascript is not for passwords. Use .htaccess or some other server-side method of verification.

Collapse -

by CptOmlly In reply to Hide/mask JavaScript pass ...

How about using the html form input type password?
Here's an example.


Related Discussions

Related Forums