"Password_Difficult "
Bootstrap 4.1.1 Snippet by sacito

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <html> <head> <script type="text/javascript"> function testPassword(passwd) { var intScore = 0 var strVerdict = "weak" var strLog = "" // PASSWORD LENGTH if (passwd.length<5) // length 4 or less { intScore = (intScore+3) strLog = strLog + "3 points for length (" + passwd.length + ")\n" } else if (passwd.length>4 && passwd.length<8) // length between 5 and 7 { intScore = (intScore+6) strLog = strLog + "6 points for length (" + passwd.length + ")\n" } else if (passwd.length>7 && passwd.length<16)// length between 8 and 15 { intScore = (intScore+12) strLog = strLog + "12 points for length (" + passwd.length + ")\n" } else if (passwd.length>15) // length 16 or more { intScore = (intScore+18) strLog = strLog + "18 point for length (" + passwd.length + ")\n" } // LETTERS (Not exactly implemented as dictacted above because of my limited understanding of Regex) if (passwd.match(/[a-z]/)) // หากมีตัวเล็กอย่างน้อย 1 ตัว { intScore = (intScore+1) strLog = strLog + "1 point for at least one lower case char\n" } if (passwd.match(/[A-Z]/)) // หากมีตัวใหญ่อย่างน้อย ๅ ตัว { intScore = (intScore+5) strLog = strLog + "5 points for at least one upper case char\n" } // NUMBERS if (passwd.match(/\d+/)) // หากมีตัวเลขอย่างน้อย 1 ตัว { intScore = (intScore+5) strLog = strLog + "5 points for at least one number\n" } if (passwd.match(/(.*[0-9].*[0-9].*[0-9])/)) // หากมีตัวเลข 0-9 อย่างน้อย 3 ตัว { intScore = (intScore+5) strLog = strLog + "5 points for at least three numbers\n" } // SPECIAL CHAR if (passwd.match(/.[!,@,#,$,%,^,&,*,?,_,~]/)) // [verified] at least one special character { intScore = (intScore+5) strLog = strLog + "5 points for at least one special char\n" } // [verified] at least two special characters if (passwd.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)) { intScore = (intScore+5) strLog = strLog + "5 points for at least two special chars\n" } // COMBOS if (passwd.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) // [verified] both upper and lower case { intScore = (intScore+2) strLog = strLog + "2 combo points for upper and lower letters\n" } if (passwd.match(/([a-zA-Z])/) && passwd.match(/([0-9])/)) // [verified] both letters and numbers { intScore = (intScore+2) strLog = strLog + "2 combo points for letters and numbers\n" } // [verified] letters, numbers, and special characters if (passwd.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/)) { intScore = (intScore+2) strLog = strLog + "2 combo points for letters, numbers and special chars\n" } if(intScore < 16) { strVerdict = "very weak" } else if (intScore > 15 && intScore < 25) { strVerdict = "weak" } else if (intScore > 24 && intScore < 35) { strVerdict = "mediocre" } else if (intScore > 34 && intScore < 45) { strVerdict = "strong" } else { strVerdict = "stronger" } // output write to form document.forms.passwordForm.score.value = (intScore) document.forms.passwordForm.verdict.value = (strVerdict) document.forms.passwordForm.matchlog.value = (strLog) } </script> </head> <body> <form name="passwordForm" id="passwordForm"> Type the password: <input type="text" name="passwd" onkeyup="testPassword(document.forms.passwordForm.passwd.value)" /> <br /><br /><br /> Strength score is: <input type="text" name="score" size="3" /> Strength verdict: <input type="text" name="verdict" size="15" /> <br /><br /><br /> Log: <br /> <textarea name="matchlog" cols="70" rows="15"></textarea> </form> </body> </html>
body { background:lightGreen; }

Related: See More


Questions / Comments: