title: Validate re-enter of password javascript code require correction
body: <p>I have this code to verify data (password) on both the fields whether it is equal.</p>
  
  <p>When I enter the password in the first field and go to second field to re-enter the password I get the error cross (fa-close) at that time.</p>
  
  <p>Instead I need that after I get out of second field, after that I get the error message.</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;input type="password" name="password" id="password" /&gt;&lt;br&gt;
  &lt;input type="password" name="password2" id="password2" onKeyUp="checkPass(); return false;" /&gt;
  &lt;span id="confirmMessage" class="confirmMessage"&gt;&lt;/span&gt;
  </code></pre>
  
  <p>Here is my javascript code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function checkPass() {
  var pass1 = document.getElementById('password');
  var pass2 = document.getElementById('password2');
  var message = document.getElementById('confirmMessage');
  
  var goodColor = "#fff";
  var goodColored = "#087a08";
  var badColor = "#fff";
  var badColored = "#ed0b0b";
  
  if(password.value == password2.value) {
    password2.style.backgroundColor = goodColor;
    message.style.color = goodColored;
    message.innerHTML = "&lt;i class='fa fa-check'&gt;&lt;/i&gt;"
  }
  else {
    password2.style.backgroundColor = badColor;
    message.style.color = badColored;
    message.innerHTML = "&lt;i class='fa fa-close'&gt;&lt;/i&gt;"
  }
  }  
  &lt;/script&gt;
  </code></pre>
  
  <p>Help will be appreciated. Thank you.</p>