<html>
<head>
<title>Password Strength</title>
</head>
<body style="color: white; background-color: #294a8f; text-align: center; text-shadow: 2px; font-family: sans-serif;">
<center>
<div>
<input type="password" id="password" placeholder="Your Password" autofocus/><br>
<button id="strength" onclick="getStrength();" style="appearance: push-button; border-color: #3b5998; background-color: #294a8f; color: white;">Strength</button>
<div id="result"></div>
<script>
function getStrength(){
var password, strength=0, result;
password=document.getElementById('password').value;
result=document.getElementById('result');
if (password.length > 7) strength += 1
if(password.length>7){
if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) strength += 1
if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/)) strength += 1
if (password.match(/([!,%,&,@,#,$,^,*,?,_,~])/)) strength += 1
if (password.match(/(.*[!,%,&,@,#,$,^,*,?,_,~].*[!,%,&,@,#,$,^,*,?,_,~])/)) strength += 1
}
if (strength < 2 ) {
strength='Weak'
} else if (strength == 2 ) {
strength='Good'
} else {
strength='Strong'
}
result.innerHTML=strength;
}
</script>
</div>
</center>
</body>
</html>
<head>
<title>Password Strength</title>
</head>
<body style="color: white; background-color: #294a8f; text-align: center; text-shadow: 2px; font-family: sans-serif;">
<center>
<div>
<input type="password" id="password" placeholder="Your Password" autofocus/><br>
<button id="strength" onclick="getStrength();" style="appearance: push-button; border-color: #3b5998; background-color: #294a8f; color: white;">Strength</button>
<div id="result"></div>
<script>
function getStrength(){
var password, strength=0, result;
password=document.getElementById('password').value;
result=document.getElementById('result');
if (password.length > 7) strength += 1
if(password.length>7){
if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) strength += 1
if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/)) strength += 1
if (password.match(/([!,%,&,@,#,$,^,*,?,_,~])/)) strength += 1
if (password.match(/(.*[!,%,&,@,#,$,^,*,?,_,~].*[!,%,&,@,#,$,^,*,?,_,~])/)) strength += 1
}
if (strength < 2 ) {
strength='Weak'
} else if (strength == 2 ) {
strength='Good'
} else {
strength='Strong'
}
result.innerHTML=strength;
}
</script>
</div>
</center>
</body>
</html>
Comments