Open
Description
What problem are you trying to solve?
Add showValidationMessage() method for validation without focus management
Problem
The current reportValidity()
method automatically refocuses the validated element when validation fails, creating poor user experience and accessibility issues.
Issues with current behavior:
- Focus trapping: Users cannot navigate away from invalid fields
- Poor UX: Interrupts natural form navigation flow
- Accessibility problems: Confuses screen reader users
Real-world scenario:
// User types invalid email, then presses Tab
emailInput.addEventListener('blur', () => {
if (!emailInput.checkValidity()) {
emailInput.reportValidity(); // Shows error BUT forces focus back
// User is now trapped - cannot move to next field
}
});
Proposed Solution
Add a new method showValidationMessage()
that displays validation errors without focus management:
// New API - message only, no focus management
element.showValidationMessage();
// Existing API - message + focus (backward compatibility)
element.reportValidity();
Use Case
Real-time validation without focus trap:
field.addEventListener('blur', () => {
if (!field.checkValidity()) {
field.showValidationMessage(); // Show error, allow navigation
}
});
This would significantly improve form validation UX while maintaining backward compatibility.
What solutions exist today?
No response
How would you solve it?
No response
Anything else?
No response