Automatically focus the first form field error

Because we’re not showing a summary of error messages screen reader users might
take a while to discover that there’s an error on the page. Since the only
real action on a page with errors is to correct them this commit adds some
Javascript to send focus straight to the first error message on a page.
This commit is contained in:
Chris Hill-Scott
2016-02-23 06:47:39 +00:00
parent 16fbfe49a3
commit 0d12714401

View File

@@ -1,3 +1,5 @@
$(() => GOVUK.modules.start()); $(() => GOVUK.modules.start());
$(() => new GOVUK.SelectionButtons('.block-label input, .sms-message-option input')); $(() => new GOVUK.SelectionButtons('.block-label input, .sms-message-option input'));
$(() => $('.error-message').eq(0).parent('label').next('input').trigger('focus'));