<!DOCTYPEÂ html>
<html>
<head></head>
<body>
    <input type="text" id="username" placeholder="Name">
    <input type="text" id="password" placeholder="Password">
    <button id="signInBtn">Login</button>
    <div id="messageText"></div>
</body>
<script>
    const username = document.querySelector('#username'),
          password = document.querySelector('#password'),
          btn = document.querySelector('#signInBtn'),
          message = document.querySelector('#messageText');
    btn.addEventListener('click', () => {
        if (!username.value) {
            message.innerHTML = 'Please Enter Username'
        } else if (!password.value) {
            message.innerHTML = 'Please Enter Password'
        } else {
            message.innerHTML = 'Welcome'
        }
    })
</script>
</html>
Comments
Leave a comment