input field password restriction code example
Example 1: Javascript validate password
let pattern = new RegExp("^(?=(.*[a-zA-Z]){1,})(?=(.*[0-9]){2,}).{8,}$");
let inputToListen = document.getElementById('pass-one');
let valide = document.getElementsByClassName('indicator')[0];
inputToListen.addEventListener('input', function () {
if(pattern.test(inputToListen.value)){
valide.innerHTML = 'ok';
}else{
valide.innerHTML = 'not ok'
}
});
Example 2: html password and username
#Check the above or below to know.