Form Submission States
You'll learn how to clearly communicate loading, success, and error states when users submit a form, ensuring everyone—including assistive technology users—understands what's happening.
Why Form States Matter
When a user clicks "Submit," they need to know what's going on. Is the form processing? Did it succeed? Did something go wrong? Without clear feedback, users might click "Submit" multiple times, abandon the process, or feel confused.
Think of form submission like sending a letter at the post office: you need to know when the clerk is processing your request (loading), when your package was accepted (success), or if something went wrong (error).
Core State Communication Techniques
aria-busy for Loading State
When a form is submitting, set aria-busy="true" on the form or submit button to inform assistive technologies that the element is updating:
form.addEventListener('submit', async (e) => {
e.preventDefault();
const submitButton = form.querySelector('button[type="submit"]');
submitButton.setAttribute('aria-busy', 'true');
submitButton.disabled = true;
submitButton.textContent = 'Submitting...';
// ... perform submission
});
Live Regions for Dynamic Updates
Use a live region with role="status" or aria-live="polite" to announce outcomes:
<div role="status" aria-live="polite" aria-atomic="true" class="status-message"></div>
// After successful submission:
statusMessage.textContent = 'Form submitted successfully!';
// After error:
statusMessage.textContent = 'Error: Please check your connection and try again.';
Reset After Completion
Always remove aria-busy and re-enable buttons when done—whether success or failure.
Key Takeaway: Use aria-busy during submission, live regions (role="status") to announce results, and clear visual/text indicators so all users understand the current form state without guessing.