Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check all associated elements for form validity
- Loading branch information
Showing
2 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...web-platform-tests/to-upstream/html/semantics/forms/constraints/using-form-attribute.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Forms outside the form element that use the form="" attribute still get validated</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<input id="the-input" type="text" form="the-form" required> | ||
<form id="the-form"></form> | ||
|
||
<script> | ||
"use strict"; | ||
|
||
test(() => { | ||
const el = document.querySelector("#the-input"); | ||
const form = document.querySelector("#the-form"); | ||
|
||
let firedInvalid = false; | ||
el.addEventListener("invalid", () => { | ||
firedInvalid = true; | ||
}); | ||
|
||
assert_false(form.checkValidity(), "checkValidity"); | ||
assert_false(form.reportValidity(), "reportValidity"); | ||
assert_true(firedInvalid, "fired invalid event"); | ||
}); | ||
</script> |