diff --git a/custom/modules/loyalist_core/js/search_input_required.js b/custom/modules/loyalist_core/js/search_input_required.js index 3cae2aa..05cfb5d 100644 --- a/custom/modules/loyalist_core/js/search_input_required.js +++ b/custom/modules/loyalist_core/js/search_input_required.js @@ -11,11 +11,8 @@ $(search_input).attr('required', true); } - // If form validity check fails then apply BS5 invalid class. - document.getElementById("edit-fulltext").addEventListener("invalid", - function () { - $(this).addClass('is-invalid').attr('aria-invalid', 'true'); - } - ); - + // If invalid event fires on search input then apply BS5 styling + ARIA. + $(search_input).on('invalid', function(event) { + $(this).addClass('is-invalid').attr('aria-invalid', 'true'); + }) })(jQuery);