samedi 1 août 2020

this code keeps saying "Username or password is wrong!"

guys this code doesn't care about value in username or password only says "Username or password is wrong!" can you fix it ? check the code you'll understand. thanks...

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>JavaScript</title>
    </head>
<body>    
<script>
    function check()
    {
        
let user_name = document.getElementById("txt1").value;
    let password = document.getElementById("txt2").value;
    if(user_name == null || password == null)
       {
           alert("You logged in!");
      
       }else 
       {
           document.getElementById("error").innerHTML = "Username or password is wrong!";
       }
    }
    </script>
    <div class="form">
    <input type="text" id="txt1" placeholder="Username"><br>
    <input type="text" id="txt2" placeholder="Password"><br>
        <input type="button" value="Log in" onclick="check()">
        <p id="error"></p>
        </div>
    </body>    
</html>

Aucun commentaire:

Enregistrer un commentaire