From 52b5e9685406164f605fcc14f530470299e017fe Mon Sep 17 00:00:00 2001 From: Kyler Date: Fri, 11 Jul 2025 01:27:15 -0600 Subject: [PATCH] Add error handling for class input and enhance error message styling --- www/index.css | 14 ++++++++++++++ www/index.html | 14 ++++++++++---- www/index.js | 13 +++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/www/index.css b/www/index.css index d8dde0f..27782c5 100644 --- a/www/index.css +++ b/www/index.css @@ -113,3 +113,17 @@ body[mode="dark"] a { .no-classes { display: none; } + +.error-message { + color: red; + font-weight: bold; + font-size: 16px; +} + +body[mode="dark"] .error-message { + color: #ff6666; +} + +.error-message.hidden { + display: none; +} diff --git a/www/index.html b/www/index.html index a702ebc..21cc99d 100644 --- a/www/index.html +++ b/www/index.html @@ -32,14 +32,21 @@

Add Class

- +

+ Please enter the class information below: + +

+ - + +

@@ -65,12 +72,11 @@

- Not Affiliated With Snow College
© 2025 Kyler Olsen Home Dark Mode Contact - Last Updated June 2025 + Not Affiliated With Snow College
diff --git a/www/index.js b/www/index.js index 6416f51..6700060 100644 --- a/www/index.js +++ b/www/index.js @@ -61,6 +61,19 @@ function remove_class(event) { } function add_class() { + // check if there is a time and at least one day selected + if (!document.querySelector("#time").value.trim() || ( + !document.querySelector("#Mon").checked && + !document.querySelector("#Tue").checked && + !document.querySelector("#Wed").checked && + !document.querySelector("#Thu").checked && + !document.querySelector("#Fri").checked + )) { + document.querySelector(".error-message").classList.remove("hidden"); + return; + } + document.querySelector(".error-message").classList.add("hidden"); + if (document.querySelector(".class-list").classList.contains("no-classes")) { document.querySelector(".class-list").classList.remove("no-classes"); }