Skip to content

Commit

Permalink
Do not validate disabled inputs
Browse files Browse the repository at this point in the history
Fixes #90
  • Loading branch information
haacked committed Jan 2, 2024
1 parent 7f36bed commit 6319905
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1234,8 +1234,8 @@ export class ValidationService {
*/
createValidator(input: ValidatableElement, directives: ValidationDirective) {
return async () => {
// only validate visible fields
if (!this.isHidden(input)) {
// only validate visible and enabled fields
if (!this.isHidden(input) && !this.isDisabled(input)) {
for (let key in directives) {
let directive = directives[key];
let provider = this.providers[key];
Expand Down Expand Up @@ -1286,6 +1286,15 @@ export class ValidationService {
return !(this.allowHiddenFields || input.offsetWidth || input.offsetHeight || input.getClientRects().length);
}

/**
* Checks if the provided input is disabled
* @param input
* @returns
*/
private isDisabled(input: HTMLElement) {
return input.getAttribute('disabled') !== null;
}

/**
* Adds addClass and removes removeClass
* @param element Element to modify
Expand Down

0 comments on commit 6319905

Please sign in to comment.