JS: add form-with-error class to body if form contain error (#48003)

This commit is contained in:
Thomas Jund 2020-11-04 15:29:37 +01:00
parent f7787357e7
commit bc361012d9
1 changed files with 8 additions and 4 deletions

View File

@ -230,12 +230,16 @@ $(function() {
if ($date_input.data('end-date')) options.endDate = $date_input.data('end-date');
$date_input.datetimepicker(options);
});
if ($('.widget-with-error').length && $('.global-errors').length == 0) {
var first_field_with_error = $($('.widget-with-error')[0]).find('input,textarea,select');
if (first_field_with_error.length) {
$(first_field_with_error)[0].focus();
// Form with error
const first_widget_with_error = document.querySelector('.widget-with-error');
if (first_widget_with_error) {
document.body.classList.add('form-with-error');
if (!document.querySelector('.global-errors')) {
const first_field_with_error = first_widget_with_error.querySelector('input,textarea,select');
first_field_with_error.focus();
}
}
$(window).bind('pageshow', function(event) {
$('form').removeClass('disabled-during-submit');
});