Project: Accessible Registration Form
Collect only necessary information
Start from a fictional workshop registration. Use visible labels, name attributes and the appropriate input types. Group the session choices with fieldset and legend. The user needs to understand what is required before submitting.
<form> <label for="email">Email (required)</label> <input id="email" name="email" type="email" required autocomplete="email"> <fieldset> <legend>Session</legend> <label> <input type="radio" name="session" value="morning" checked> Morning </label> <label> <input type="radio" name="session" value="afternoon"> Afternoon </label> </fieldset></form>An empty required email is invalid; the selected session has a named value.
Connect errors to the control
After checking a value, explain the specific error in text and associate it with the field. The following example is a snapshot of an invalid state, not a complete validation handler. aria-invalid communicates a state but does not perform validation. Clear stale messages when corrected.
<label for="mail">Email</label><input id="mail" type="email" value="wrong" aria-invalid="true" aria-describedby="error"><p id="error">Enter an address such as learner@example.com.</p>The invalid field references a concrete correction message.
Preview a submission locally
Native validation blocks invalid ordinary submissions. In this local example a submit handler cancels valid submission and displays only the selected session using textContent. Do not enter real contact information. A production registration must independently verify input and permissions at the server.
<main> <h1>Workshop registration</h1> <form id="registration" action="#registration" method="post"> <fieldset> <legend>Contact</legend> <label for="email">Email (required)</label> <input id="email" name="email" type="email" autocomplete="email" required aria-describedby="hint"> <p id="hint">Enter a valid email address.</p> </fieldset> <fieldset> <legend>Session</legend> <label> <input type="radio" name="session" value="morning" checked> Morning </label> <label> <input type="radio" name="session" value="afternoon"> Afternoon </label> </fieldset> <button type="submit" disabled>Preview registration</button> <output id="result" aria-live="polite"></output> </form></main><script> const form=document.querySelector('#registration');form.addEventListener('submit',event=>{event.preventDefault();const data=new FormData(form);document.querySelector('#result').textContent='Selected session: '+data.get('session')+' (not sent)';});form.querySelector('button').disabled=false;</script>The form is ready for local interaction; no registration is performed.
Common mistakes and practice
Test empty and malformed values, keyboard access, radio selection, and the valid local preview. Verify no external request is made. Do not store passwords or personal data in this project; server-side validation is outside the static demo. See projects/registration.html.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Project: Accessible Registration Form — Knowledge Check
Apply the project design and review concepts taught in this lesson.
What groups related radio choices?
Which attribute contributes the key to submitted data?
Does aria-invalid enforce validity?
How does a local preview stop ordinary submission?
Where must registration eligibility be verified?