Unverified Commit e0c5ffb6 authored by Frederic Massart's avatar Frederic Massart
Browse files

MDL-57061 theme_boost: Focus the invalid form elements on error

parent 0fbe41f4
......@@ -38,15 +38,24 @@ define(['jquery', 'core/event'], function($, Event) {
parent.addClass('has-danger');
parent.data('client-validation-error', true);
$(element).addClass('form-control-danger');
$(element).attr('aria-describedby', $(element).attr('id') + '-feedback');
$(element).attr('aria-describedby', feedback.attr('id'));
$(element).attr('aria-invalid', true);
feedback.attr('tabindex', 0);
feedback.html(msg);
feedback.show();
// Only display and focus when the error was not already visible.
if (!feedback.is(':visible')) {
feedback.show();
feedback.focus();
}
} else {
if (parent.data('client-validation-error') === true) {
parent.removeClass('has-danger');
parent.data('client-validation-error', false);
$(element).removeClass('form-control-danger');
$(element).attr('aria-describedby', '');
$(element).removeAttr('aria-describedby');
$(element).attr('aria-invalid', false);
feedback.hide();
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment