67 lines
1.6 KiB
JavaScript
67 lines
1.6 KiB
JavaScript
{077f4ca28d29531e40cc506be135f568ce282f87 true 1588 main.js 0xc001fd4540}
let pass = document.getElementById('pass');
|
|
let toggleBtn = document.getElementById('toggleBtn');
|
|
|
|
|
|
let lowerCase = document.getElementById('lower');
|
|
let upperCase = document.getElementById('upper');
|
|
let digit = document.getElementById('number');
|
|
let specialChar = document.getElementById('special');
|
|
let minlength = document.getElementById('length');
|
|
|
|
function checkPassword(data){
|
|
|
|
const lower = new RegExp('(?=.*[a-z])');
|
|
const upper = new RegExp('(?=.*[A-Z])');
|
|
const number = new RegExp('(?=.*[0-9])');
|
|
const special = new RegExp('(?=.*[!@#\$%\^&\*])');
|
|
const length = new RegExp('(?=.{8,})');
|
|
|
|
// lower
|
|
if(lower.test(data)){
|
|
lowerCase.classList.add('valid');
|
|
} else {
|
|
lowerCase.classList.remove('valid');
|
|
}
|
|
// upper
|
|
if(upper.test(data)){
|
|
upperCase.classList.add('valid');
|
|
} else {
|
|
upperCase.classList.remove('valid');
|
|
}
|
|
// number
|
|
if(number.test(data)){
|
|
digit.classList.add('valid');
|
|
} else {
|
|
digit.classList.remove('valid');
|
|
}
|
|
// special
|
|
if(special.test(data)){
|
|
specialChar.classList.add('valid');
|
|
} else {
|
|
specialChar.classList.remove('valid');
|
|
}
|
|
// length
|
|
if(length.test(data)){
|
|
minlength.classList.add('valid');
|
|
} else {
|
|
minlength.classList.remove('valid');
|
|
}
|
|
}
|
|
|
|
|
|
// Show\Hide
|
|
toggleBtn.onclick = function(){
|
|
if(pass.type === 'password'){
|
|
pass.setAttribute('type', 'text');
|
|
toggleBtn.classList.add('hide');
|
|
} else {
|
|
pass.setAttribute('type', 'password');
|
|
toggleBtn.classList.remove('hide');
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|