Created
May 15, 2015 03:06
-
-
Save ja6z/f75487342a9cdc027a00 to your computer and use it in GitHub Desktop.
Untitled
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function passwordChanged() { | |
var strength = document.getElementById('strength'); | |
var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\W).*$", "g"); | |
var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g"); | |
var enoughRegex = new RegExp("(?=.{6,}).*", "g"); | |
var pwd = document.getElementById("password"); | |
if (pwd.value.length==0) { | |
strength.innerHTML = 'Type Password'; | |
} else if (false == enoughRegex.test(pwd.value)) { | |
strength.innerHTML = 'More Characters'; | |
} else if (strongRegex.test(pwd.value)) { | |
strength.innerHTML = '<span style="color:green">Strong!</span>'; | |
} else if (mediumRegex.test(pwd.value)) { | |
strength.innerHTML = '<span style="color:orange">Medium!</span>'; | |
} else { | |
strength.innerHTML = '<span style="color:red">Weak!</span>'; | |
} | |
} | |
</script><input name="password" id="password" type="text" size="15" maxlength="20" onkeyup="return passwordChanged();" /> | |
<span id="strength">Type Password</span> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"result"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment