Skip to content

Commit

Permalink
use custom validity message on last example
Browse files Browse the repository at this point in the history
  • Loading branch information
joelhawksley committed Nov 26, 2024
1 parent e715aaf commit aedf260
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ <h2 tabindex="-1" id="success2" class="success" hidden>Your submission was succe
<button value="2" name="form">submit</button>
</form>

<h2>only-validate-on-blur</h2>
<h2>only-validate-on-blur with custom validity messages</h2>
<h2 tabindex="-1" id="success3" class="success" hidden>Your submission was successful</h2>
<form>
<form id="custom2">
<p>All fields marked with * are required</p>

<label for="simple-field2">Desired username*:</label>
Expand Down Expand Up @@ -86,7 +86,7 @@ <h2 tabindex="-1" id="success3" class="success" hidden>Your submission was succe
})

form.addEventListener('auto-check-start', () => {
if (form.id === 'custom') {
if (form.id.includes('custom')) {
const {setValidity} = event.detail
setValidity('🔍 Checking validity...')
}
Expand All @@ -96,7 +96,7 @@ <h2 tabindex="-1" id="success3" class="success" hidden>Your submission was succe
state.textContent = 'succeeded'
})
form.addEventListener('auto-check-error', event => {
if (form.id === 'custom') {
if (form.id.includes('custom')) {
const {setValidity} = event.detail
setValidity('🚫 Something went wrong. Please try again')
}
Expand Down

0 comments on commit aedf260

Please sign in to comment.