I can't figure out why my code doesn't validate my input value. I get "not working" for all scenarios.
This is my code:
<body>
<input type="text" placeholder="User Name" id="id_inputuser"/>
<label>Enter User Name</label><br>
<input type="text" placeholder="Password"id="id_inputpass"/>
<label>Enter Password</label><br><br>
<button onClick="verify()">Enter</button>
</body>
Javascript:
var user = document.querySelector('#id_inputuser').value;
function verify()
{if (user == "david")
{alert("working");}
else{alert("not working")};
}
Can someone help?
Thanks a lot!