diff options
author | RossTheRoss <mstrapp@protonmail.com> | 2021-05-16 21:38:59 -0500 |
---|---|---|
committer | RossTheRoss <mstrapp@protonmail.com> | 2021-05-16 21:38:59 -0500 |
commit | 9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c (patch) | |
tree | 9e739b11361f5fd122b31cfce107947502b69809 /csci4131/hw4/strap012/passwordcheck.js | |
parent | Add trash (diff) | |
download | homework-9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c.tar homework-9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c.tar.gz homework-9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c.tar.bz2 homework-9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c.tar.lz homework-9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c.tar.xz homework-9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c.tar.zst homework-9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c.zip |
Rearrange files
Diffstat (limited to 'csci4131/hw4/strap012/passwordcheck.js')
-rw-r--r-- | csci4131/hw4/strap012/passwordcheck.js | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/csci4131/hw4/strap012/passwordcheck.js b/csci4131/hw4/strap012/passwordcheck.js deleted file mode 100644 index 97a2918..0000000 --- a/csci4131/hw4/strap012/passwordcheck.js +++ /dev/null @@ -1,42 +0,0 @@ -var input; -var result = document.querySelector("span"); -window.addEventListener('DOMContentLoaded', (event) => { - input = document.getElementsByName("password")[0]; -}); -function checkStrength() { - var password = input.value; - var strength = 0; - if (password.length < 6) { - result.removeAttribute("class"); - result.classList.add('short'); - result.innerHTML = "Too short"; - return; - } - if (password.length > 7) { strength += 1;} - // If password contains both lower and uppercase characters, increase strength value. - if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) { strength += 1;} - // If it has numbers and characters, increase strength value. - if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/)) { strength += 1;} - // If it has one special character, increase strength value. - if (password.match(/([!,%,&,@,#,$,^,*,?,_,~])/)) { strength += 1;} - // If it has two special characters, increase strength value. - if (password.match(/(.*[!,%,&,@,#,$,^,*,?,_,~].*[!,%,&,@,#,$,^,*,?,_,~])/)) { strength += 1;} - // Calculated strength value, we can return messages - // If value is less than 2 - if (strength < 2) { - result.removeAttribute("class"); - result.classList.add('weak'); - result.innerHTML = 'Weak'; - return; - } else if (strength == 2) { - result.removeAttribute("class"); - result.classList.add('good'); - result.innerHTML = 'Good'; - return; - } else { - result.removeAttribute("class"); - result.classList.add('strong'); - result.innerHTML = 'Strong'; - return; - } -} |