Skip to content

Commit

Permalink
fix: only validate required input fields
Browse files Browse the repository at this point in the history
  • Loading branch information
petterip committed Nov 15, 2024
1 parent ce17437 commit 081ea7c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions views/settings/settingsBase.html
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 081ea7c

Please sign in to comment.