lundi 9 avril 2018

Javascript if...else issue

I'm new in html/css/javascript programming and I face an issue when trying to use the else...if statement.

here is my html code :

<!DOCTYPE html>
<html>
<head>
    <script type="text/javascript" src="login.js"></script>
    <title>Login</title>
</head>

<body>

<input id="identifiant" type="text" placeholder="Login" autofocus><br>
<input id="mdp" type="password" placeholder="Password"><br><br>

<select>
<option>English
<option>Français
<option>Español
<option>Deutsch
</select> <br><br>

<button onclick="test()">Connection</button><br><br>

<a href="Recover password.html"> I forgot my password


</body>
</html>

here is my javascript code :

function test(){
    var identifiant=document.getElementById("identifiant");
    var mdp = document.getElementById("mdp");
if (identifiant=="keyboard" && mdp=="mouse"){alert("ok")} else {alert("non")};
}

The problem is that the function test() always returns the else statement even if the ID and password are correct. (picture here)

Any idea where i'm going wrong ?

Thanks for your help.

Aucun commentaire:

Enregistrer un commentaire