diff --git a/src/index.ts b/src/index.ts index 876ec75..e796e4b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -539,6 +539,11 @@ export class ValidationService { // we could use 'matches', but that's newer than querySelectorAll so we'll keep it simple and compatible. forms.push(root); } + // If root is the descendant of a form, we want to include that form too. + const containingForm = (root instanceof Element) ? root.closest('form') : null; + if (containingForm) { + forms.push(containingForm); + } for (let form of forms) { let validationMessageElements = Array.from(form.querySelectorAll('[data-valmsg-for]'));