Just started learning javascript and started to using an external js file. Starting trying to make a password strength checker. But pass keeps coming up as undefined. I cant seem to find the problem. Thanks for your time and help.
The js file
pass.addEventListener('keyup', function(){
stength();
})
function strength() {
var val = document.getElementById("pass").value;
var status = document.getElementById("length").value;
var counter = 0;
if (val != ""){
if(val.length <= 6)
counter=1;
if(val.length >= 7 && val.length <= 10)
counter=2;
if(val.length < 10)
counter=3;
if (counter == 1) {
status.innerHTML="Weak";
status.style.background="#fc2407";
status.style.color="#ffffff";
}
if (counter == 2) {
status.innerHTML="Good";
status.style.background="#fc9e07";
status.style.color="#ffffff";
}
if (counter == 3) {
status.innerHTML="Strong";
status.style.background="#21dd53";
status.style.color="#ffffff";
}
}
}
The html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Title</title>
<script src="index.js"></script>
</head>
<body>
<div class="wrap text-center">
<p class="head">Enter Password</p>
<input type="password" id="pass"/>
</div>
<div class="wrap text-center">
<p class="head"> Password Strength</p>
<p ckass="strength" id="length"></p>
</div>
</body>
</html>