Skip to content

Commit

Permalink
Set novalidate when we first see a form
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlbyk committed Aug 13, 2023
1 parent e3d0ff4 commit f9accb7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,14 @@ export class ValidationService {
let add = (this.formInputs[formUID].indexOf(inputUID) === -1);
if (add) {
this.formInputs[formUID].push(inputUID);

if (this.options.addNoValidate) {
this.logger.log('Setting novalidate on form', form);
form.setAttribute('novalidate', 'novalidate');
}
else {
this.logger.log('Not setting novalidate on form', form);
}
}
else {
this.logger.log("Form input for UID '%s' is already tracked", inputUID);
Expand Down Expand Up @@ -959,9 +967,6 @@ export class ValidationService {
for (let i = 0; i < inputs.length; i++) {
let input = inputs[i];
this.addInput(input);
if (this.options.addNoValidate) {
input.closest('form')?.setAttribute('novalidate', 'novalidate');
}
}
}

Expand Down

0 comments on commit f9accb7

Please sign in to comment.