-
Improvement
-
Resolution: Fixed
-
Minor
-
4.4
-
MOODLE_404_STABLE
-
MOODLE_404_STABLE
-
MDL-81066-main -
When form fields have client-side validation (usually for 'required' or 'regex' types), the validation runs when you tab out of the field.
As originally filed in MDL-80851, this is not very accessible because given that you have just left the field, it's difficult to report an error to screen readers. There is a common behaviour among screenreader users to tab through all form fields to see what is available, and this results in a bunch of extra tab stops and warning messages all through.
Jun suggested the possibility of changing the validation to run only when the form is submitted. This improves the interface for screenreader and keyboard users (no extra tab stops when completing the form) and is also a bit cleaner for sighted users if you don't fill the form in order (avoiding extra messages appearing). It does have the disadvantage that you don't get feedback quite as fast if you forget a required field, but for a mouse user, you could easily miss out a required field without ever visiting that field, so you won't know about it until you submit anyway (i.e. no real change).
Another advantage is that this is consistent with server-side validation, which obviously only happens after you submit the form.
The specific change is that validation occurs on tab key if you change the value of the field (change event), but does not occur if you tab through it without changing it (blur event). In the latter case, validation will still occur when you press the submit button, and the form will scroll back up to show the first affected field.
Note I have not attempted to use the browser 'required' feature, which causes the browser to prohibit form submission in a similar way itself; this would be a larger change with more details to resolve (browser wouldn't let you submit using 'cancel' button either), and wouldn't handle the other client-side validation that isn't required [regex].