aboutsummaryrefslogtreecommitdiffstats
path: root/OLD/csci4131/hw3/strap012/passwordcheck.js
diff options
context:
space:
mode:
authorMatt Strapp <matt@mattstrapp.net>2022-05-24 11:18:46 -0500
committerMatt Strapp <matt@mattstrapp.net>2022-05-24 11:19:55 -0500
commit7a73162607544204032aa66cce755daf21edebda (patch)
tree58578e01f15f34a855d99c32898db9d7a1603e67 /OLD/csci4131/hw3/strap012/passwordcheck.js
parentdo some stuff (diff)
downloadhomework-7a73162607544204032aa66cce755daf21edebda.tar
homework-7a73162607544204032aa66cce755daf21edebda.tar.gz
homework-7a73162607544204032aa66cce755daf21edebda.tar.bz2
homework-7a73162607544204032aa66cce755daf21edebda.tar.lz
homework-7a73162607544204032aa66cce755daf21edebda.tar.xz
homework-7a73162607544204032aa66cce755daf21edebda.tar.zst
homework-7a73162607544204032aa66cce755daf21edebda.zip
Graduate
Signed-off-by: Matt Strapp <matt@mattstrapp.net>
Diffstat (limited to 'OLD/csci4131/hw3/strap012/passwordcheck.js')
-rw-r--r--OLD/csci4131/hw3/strap012/passwordcheck.js42
1 files changed, 0 insertions, 42 deletions
diff --git a/OLD/csci4131/hw3/strap012/passwordcheck.js b/OLD/csci4131/hw3/strap012/passwordcheck.js
deleted file mode 100644
index 97a2918..0000000
--- a/OLD/csci4131/hw3/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;
- }
-}