From a0a903009debde3d1610629e44c3ec9bc47465a1 Mon Sep 17 00:00:00 2001 From: DeNNiiInc Date: Sat, 27 Dec 2025 20:40:14 +1100 Subject: [PATCH] Feat: Auto-trim whitespace from input fields on blur --- public/script.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/public/script.js b/public/script.js index b4185c8..d267d37 100644 --- a/public/script.js +++ b/public/script.js @@ -239,6 +239,19 @@ function displayErrorWithTips(errorMessage, container) { container.innerHTML = errorMessage + tipsHTML; } +// =================================== +// AUTO-TRIM INPUT FIELDS +// =================================== +// Automatically trim whitespace from all text inputs on blur +document.addEventListener('DOMContentLoaded', () => { + const textInputs = document.querySelectorAll('input[type="text"], input[type="email"], input[type="password"]'); + textInputs.forEach(input => { + input.addEventListener('blur', function() { + this.value = this.value.trim(); + }); + }); +}); + // =================================== // PASSWORD TOGGLE // ===================================