Skip to content

Commit ab9fcff

Browse files
authored
Merge pull request #67 from github/show-form-submission-success-messages
Show form submission success messages
2 parents d39de49 + 3426757 commit ab9fcff

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

examples/index.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +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>
1617
<form>
1718
<p>All fields marked with * are required</p>
1819

@@ -21,11 +22,12 @@ <h2>Simple form</h2>
2122
<input id="simple-field" autofocus name="foo" required />
2223
<code class="state"></code>
2324
</auto-check>
24-
<button>submit</button>
25+
<button value="1" name="form">submit</button>
2526
</form>
2627

2728
<h2>Form that has custom validity messages</h2>
2829
<p>Input 422 for an error response.</p>
30+
<p id="success2" class="success" hidden>Your submission was successful</p>
2931
<form id="custom">
3032
<p>All fields marked with * are required</p>
3133

@@ -34,11 +36,13 @@ <h2>Form that has custom validity messages</h2>
3436
<input id="custom-field" autofocus class="json" name="foo" required />
3537
<code class="state"></code>
3638
</auto-check>
37-
<button>submit</button>
39+
<button value="2" name="form">submit</button>
3840
</form>
3941
</main>
4042

4143
<script>
44+
let successN = new URL(window.location).searchParams.get('form')
45+
if (successN) document.getElementById(`success${successN}`).hidden = false
4246
let focusedInput
4347
const nativeFetch = window.fetch
4448
const fakeFetch = function (_, options) {

src/auto-check-element.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class AutoCheckValidationEvent extends AutoCheckEvent {
3030
super(phase)
3131
}
3232

33-
setValidity(message: string) {
33+
setValidity = (message: string) => {
3434
this.message = message
3535
}
3636
}

0 commit comments

Comments
 (0)