Skip to content

Commit

Permalink
Merge pull request #67 from github/show-form-submission-success-messages
Browse files Browse the repository at this point in the history
Show form submission success messages
  • Loading branch information
keithamus authored Jul 5, 2023
2 parents d39de49 + 3426757 commit ab9fcff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<h1>auto-check-element</h1>
<h2>Simple form</h2>
<p>Input 422 for an error response.</p>
<p id="success1" class="success" hidden>Your submission was successful</p>
<form>
<p>All fields marked with * are required</p>

Expand All @@ -21,11 +22,12 @@ <h2>Simple form</h2>
<input id="simple-field" autofocus name="foo" required />
<code class="state"></code>
</auto-check>
<button>submit</button>
<button value="1" name="form">submit</button>
</form>

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

Expand All @@ -34,11 +36,13 @@ <h2>Form that has custom validity messages</h2>
<input id="custom-field" autofocus class="json" name="foo" required />
<code class="state"></code>
</auto-check>
<button>submit</button>
<button value="2" name="form">submit</button>
</form>
</main>

<script>
let successN = new URL(window.location).searchParams.get('form')
if (successN) document.getElementById(`success${successN}`).hidden = false
let focusedInput
const nativeFetch = window.fetch
const fakeFetch = function (_, options) {
Expand Down
2 changes: 1 addition & 1 deletion src/auto-check-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AutoCheckValidationEvent extends AutoCheckEvent {
super(phase)
}

setValidity(message: string) {
setValidity = (message: string) => {
this.message = message
}
}
Expand Down

0 comments on commit ab9fcff

Please sign in to comment.