[Solved] How to change form background color on focus loss when text is entered?


blur is what you are looking for.

document.write("<input type="text">");
var input = document.querySelector('input');
input.addEventListener('focus',function(){
  input.style.backgroundColor = "purple";
})
input.addEventListener('blur',function(){
  if(input.value != ""){
      input.style.backgroundColor = "green";
  }
})

0

solved How to change form background color on focus loss when text is entered?