fix(forms): preserve regex quantifiers and use inline constraint errors
This commit is contained in:
1 parent
1dd60ded0d
commit
fe40cc56df
13 files changed
+132
-26
No files matched your search
@@ -41,7 +41,16 @@ component StrongPassword {
|
||||
state detailsOpen: boolean = false
|
||||
state revealed: boolean = false
|
||||
|
||||
state nativeError: string = ""
|
||||
|
||||
functions {
|
||||
client function handleInvalid(sourceEvent) {
|
||||
sourceEvent.preventDefault()
|
||||
sourceEvent.stopPropagation()
|
||||
nativeError = validationMessage || (sourceEvent.currentTarget.validity.valueMissing ? "Enter your password." : "Enter a password that meets the requirements.")
|
||||
sourceEvent.currentTarget.setAttribute("aria-invalid", "true")
|
||||
}
|
||||
|
||||
shared function hasMinimumLength() {
|
||||
return password.length >= Number(minLength)
|
||||
}
|
||||
@@ -146,11 +155,11 @@ component StrongPassword {
|
||||
disabled="{disabled}"
|
||||
readonly="{readonly}"
|
||||
required="{required}"
|
||||
aria-invalid="{invalid ? 'true' : 'false'}"
|
||||
aria-describedby="{validationMessage ? name + '-validation' : hintText ? name + '-hint' : ''}"
|
||||
aria-invalid="{invalid || nativeError ? 'true' : 'false'}"
|
||||
aria-describedby="{(validationMessage || nativeError) ? name + '-validation' : hintText ? name + '-hint' : ''}"
|
||||
@focus="detailsOpen = true"
|
||||
@blur="detailsOpen = false"
|
||||
@input="password = event.target.value; output.input({ value: password, score: score(), maximumScore: maximumScore(), percent: strengthPercent(), level: strengthLevel() }); output.strength({ value: password, score: score(), maximumScore: maximumScore(), percent: strengthPercent(), level: strengthLevel() })"
|
||||
@invalid="handleInvalid(event)" @input="nativeError = ''; password = event.target.value; output.input({ value: password, score: score(), maximumScore: maximumScore(), percent: strengthPercent(), level: strengthLevel() }); output.strength({ value: password, score: score(), maximumScore: maximumScore(), percent: strengthPercent(), level: strengthLevel() })"
|
||||
@change="output.change({ value: password, score: score(), maximumScore: maximumScore(), percent: strengthPercent(), level: strengthLevel() })"
|
||||
/>
|
||||
<button
|
||||
@@ -231,7 +240,7 @@ component StrongPassword {
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<small id="{name}-validation" class="wrn-next__validation" data-error="{name}">{validationMessage}</small>
|
||||
<small id="{name}-validation" class="wrn-next__validation" data-error="{name}">{(validationMessage || nativeError)}</small>
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user