fix: more complete log in username error messages

This commit is contained in:
fsylvain committed 2026-10-05 16:04:24 +02:00
1 parent 8ad3941f6d
commit d8f171b8cc
3 files changed
+37 -1

No files matched your search

+15 -1
View File
@@ -134,8 +134,22 @@ function focusFirstInvalid() {
}
}
function usernameProblem(value: string) {
const trimmed = value.trim()
if (trimmed.includes('@')) {
return 'Use your username, not your email address.'
}
if (trimmed.length < 3) {
return 'Use at least 3 characters.'
}
if (trimmed.length > 20) {
return 'Use 20 characters or fewer.'
}
return ''
}
function validate() {
usernameError.value = username.value.trim().length < 3 ? 'Use at least 3 characters.' : ''
usernameError.value = usernameProblem(username.value)
passwordError.value = password.value.length === 0 ? 'Enter your password.' : ''
return !usernameError.value && !passwordError.value
}