Skip to content

Commit 07a20ae

Browse files
committed
focus form success messages upon submission
1 parent ad8b7cf commit 07a20ae

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

examples/index.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<h1>auto-check-element</h1>
1414
<h2>Simple form</h2>
1515
<p>Input 422 for an error response.</p>
16-
<p id="success1" class="success" hidden>Your submission was successful</p>
16+
<h2 tabindex="-1" id="success1" class="success" hidden>Your submission was successful</h2>
1717
<form>
1818
<p>All fields marked with * are required</p>
1919

@@ -27,7 +27,7 @@ <h2>Simple form</h2>
2727

2828
<h2>Form that has custom validity messages</h2>
2929
<p>Input 422 for an error response.</p>
30-
<p id="success2" class="success" hidden>Your submission was successful</p>
30+
<h2 tabindex="-1" id="success2" class="success" hidden>Your submission was successful</h2>
3131
<form id="custom">
3232
<p>All fields marked with * are required</p>
3333

@@ -42,7 +42,10 @@ <h2>Form that has custom validity messages</h2>
4242

4343
<script>
4444
let successN = new URL(window.location).searchParams.get('form')
45-
if (successN) document.getElementById(`success${successN}`).hidden = false
45+
if (successN) {
46+
document.getElementById(`success${successN}`).hidden = false
47+
document.getElementById(`success${successN}`).focus()
48+
}
4649
let focusedInput
4750
const nativeFetch = window.fetch
4851
const fakeFetch = function (_, options) {

0 commit comments

Comments
 (0)