Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <title>password strength meter</title>
</head>
  <body>
    Password:<br>
    <input type="password" id="pwd" placeholder="enter password"><br>
    <progress id="strength" value="0" max="5"></progress>
  </body>
</html>
 
function passwordStrength(pw) {
  return /.{8,}/.test(pw) * (  /* at least 8 characters */
    /.{12,}/.test(pw)          /* bonus if longer */
    + /[a-z]/.test(pw)         /* a lower letter */
    + /[A-Z]/.test(pw)         /* a upper letter */
    + /\d/.test(pw)            /* a digit */
    + /[^A-Za-z0-9]/.test(pw)  /* a special character */
   )
}
let pwInput = document.getElementById("pwd")
pwInput.addEventListener('keyup', function() { 
 document.getElementById("strength").value = 
 passwordStrength(pwInput.value)
})
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
oliworxpro
0viewers