Skip to content

Commit

Permalink
(fix) refactor nested conditions materializecss#437
Browse files Browse the repository at this point in the history
  • Loading branch information
gselderslaghs committed Oct 31, 2024
1 parent 66642e6 commit cbd491f
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/forms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,14 @@ export class Forms {
let lenAttr = parseInt(textfield.getAttribute('data-length'));
let len = textfield.value.length;

if (len === 0 && textfield.validity.badInput === false && !textfield.required ) {
if (textfield.classList.contains('validate')) {
if (len === 0 && textfield.validity.badInput === false && !textfield.required && textfield.classList.contains('validate')) {
textfield.classList.remove('invalid');
} else if (textfield.classList.contains('validate')) {
// Check for character counter attributes
if (((textfield.validity.valid) && hasLength && len <= lenAttr) || textfield.validity.valid && !hasLength) {
textfield.classList.remove('invalid');
}
} else {

if (textfield.classList.contains('validate')) {
// Check for character counter attributes
if (((textfield.validity.valid) && hasLength && len <= lenAttr) || textfield.validity.valid && !hasLength) {
textfield.classList.remove('invalid');
} else {
textfield.classList.add('invalid');
}
} else {
textfield.classList.add('invalid');
}
}
}
Expand Down

0 comments on commit cbd491f

Please sign in to comment.