aboutsummaryrefslogtreecommitdiffstats
path: root/csci4131/hw2
diff options
context:
space:
mode:
authorRossTheRoss <mstrapp@protonmail.com>2021-02-10 16:19:32 -0600
committerRossTheRoss <mstrapp@protonmail.com>2021-02-10 16:19:32 -0600
commiteea1513fe3b0ba1c1c513a9cc8fe5667041a29ce (patch)
tree3edb28fb9c31345eb4aed6785e3549f7e5407bdf /csci4131/hw2
parenti hate everything (diff)
downloadhomework-eea1513fe3b0ba1c1c513a9cc8fe5667041a29ce.tar
homework-eea1513fe3b0ba1c1c513a9cc8fe5667041a29ce.tar.gz
homework-eea1513fe3b0ba1c1c513a9cc8fe5667041a29ce.tar.bz2
homework-eea1513fe3b0ba1c1c513a9cc8fe5667041a29ce.tar.lz
homework-eea1513fe3b0ba1c1c513a9cc8fe5667041a29ce.tar.xz
homework-eea1513fe3b0ba1c1c513a9cc8fe5667041a29ce.tar.zst
homework-eea1513fe3b0ba1c1c513a9cc8fe5667041a29ce.zip
I hate JS so much
Diffstat (limited to '')
-rw-r--r--csci4131/hw2/strap012/passwordcheck.js15
1 files changed, 9 insertions, 6 deletions
diff --git a/csci4131/hw2/strap012/passwordcheck.js b/csci4131/hw2/strap012/passwordcheck.js
index 53e9b3f..97a2918 100644
--- a/csci4131/hw2/strap012/passwordcheck.js
+++ b/csci4131/hw2/strap012/passwordcheck.js
@@ -1,16 +1,16 @@
-var input = document.getElementById("password");
+var input;
var result = document.querySelector("span");
-// result.onload = function() {setResult()};
-// function setResult() {
-// result = document.querySelector("span");
-// }
+window.addEventListener('DOMContentLoaded', (event) => {
+ input = document.getElementsByName("password")[0];
+});
function checkStrength() {
- var password = document.getElementById("password").value;
+ 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.
@@ -27,13 +27,16 @@ function checkStrength() {
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;
}
}