I am trying to make a password system, but I don't know the password. Whatever the password is, it is contained in a variable. I am trying:
<input type="password" id="pass">
<button onclick="pass()">Go</button>
<script>
var password = document.getElementById("pass").value;
var answer = "the password"
function pass() {
if (password == answer) {
window.location.replace("http://example.com");
}
else {
document.getElementById("note").innerHTML = "<p style='color:red'>Wrong username or password. Try again?</p>";
}
}
</script>
and it didn't work. Is there a way to check if a variable's value is the same as another's? Thanks!
Aucun commentaire:
Enregistrer un commentaire