From 081ea7cef8d5fd5a951f33b774fb5c179458e6a0 Mon Sep 17 00:00:00 2001 From: Petteri Ponsimaa Date: Fri, 15 Nov 2024 21:37:38 +0200 Subject: [PATCH] fix: only validate required input fields --- views/settings/settingsBase.html | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/views/settings/settingsBase.html b/views/settings/settingsBase.html index b58c5270..88f79499 100644 --- a/views/settings/settingsBase.html +++ b/views/settings/settingsBase.html @@ -83,13 +83,14 @@ }, 5000); }, isFormValid(form) { - const visibleFieldsValid = Array.from(form.elements) - .filter(element => element.offsetParent !== null) - .every(element => element.checkValidity()); + const inputSelector = 'input[type=\'password\'][required], input[type=\'text\'][required]'; + const requiredFields = form.querySelectorAll(inputSelector); + const visibleFieldsValid = Array.from(requiredFields) + .filter(element => element.offsetParent !== null) + .every(element => element.checkValidity()); - const inputSelector = 'input[type=\'password\'], input[type=\'text\']'; if(!visibleFieldsValid) { - form.querySelectorAll(inputSelector).forEach(input => { + requiredFields.forEach(input => { if (input.offsetParent === null) return; input.checkValidity();