I am trying to toggle button disable attribute using javascript. The button should be clickable only when username is more than 8 character and something should be typed in the password. But it's not working for some reason
let user = document.getElementById('p/u/e');
let pass = document.getElementById('password');
let submit = document.getElementById('submit');
if (user.value.length < 8 || pass.value.length == "")
{
submit.disabled = true;
}
else
{
submit.disabled = false;
}
input[type="text"], input[type="password"] {
display: block;
width: 250px;
height: 35px;
margin: 10px;
border-radius: 3px;
border: 1px solid rgb(219,219,219);
}
input[type="text"]::placeholder, input[type="password"]::placeholder {padding-left: 10px;}
button[type="submit"] {
display: block;
height: 30px;
width: 250px;
margin: 10px;
margin-top: 0px;
background-color: rgb(0,149,246);
border-radius: 3px;
border: none;
color: rgb(255, 255, 255);
font-weight: bold;
}
<input type="text" name="p/u/e" id="p/u/e" placeholder="Phone number, Username or Email">
<input type="password" name="password" id="password" placeholder="Password">
<button type="submit" id="submit">Log In</button>