jQuery(document).ready(function () { var letter = document.getElementById("letter"); var number = document.getElementById("number"); var length = document.getElementById("length"); var userpass = jQuery("body").hasClass("user-logged-in"); if (userpass == false) { var myInput = document.getElementById("edit-logged-out-password"); if (myInput) { // When the user clicks on the password field, show the message box myInput.onfocus = function () { document.getElementById("account-pass-restrictions").style.display = "block"; } // When the user clicks outside of the password field, hide the message box myInput.onblur = function () { document.getElementById("message").style.display = "none"; } // When the user starts to type something inside the password field myInput.onkeyup = function () { // Validate lowercase letters var lowerCaseLetters = /[\w-\.]+@([\w-]+\.)+[\w-]{2,4}/g; if (myInput.value.match(lowerCaseLetters)) { letter.classList.remove("vld"); letter.classList.add("invld"); } else { letter.classList.remove("invld"); letter.classList.add("vld"); } // Validate numbers var numbers = /[0-9]/g; if (myInput.value.match(numbers)) { number.classList.remove("invld"); number.classList.add("vld"); } else { number.classList.remove("vld"); number.classList.add("invld"); } // Validate length if (myInput.value.length >= 8) { length.classList.remove("invld"); length.classList.add("vld"); } else { length.classList.remove("vld"); length.classList.add("invld"); } } } } });