how would you validate and display password using javascript simply?

i want to take password and be sure they are compatible with the characters in the password input and turn the text green when valid

pass.onfocus = function() {
  msg.style.display = 'block'
}
pass.onblur = function() {
  msg.style.display = 'none'
}
pass.onkeyup = function() {
  if (pass.match(lowerCase)) {
    letter.classList.remove('invalid');
    letter.classList.add('valid');

  } else {
    letter.classList.remove('vaild');
    letter.classList.add('invalid');
  }

  if (pass.match(capitalLetters)) {
    capital.classList.remove('valid');
    capital.classList.add('invalid');
  } else {
    capital.classList.remove('invalid');
    capital.classList.add('valid');
  }

i tried turning the text for the rules to vaild and green but i want it to display at the same time