From 4cd0844da5287564c93829ab8b6be24739b670b0 Mon Sep 17 00:00:00 2001 From: Jeremy McDermott Date: Mon, 12 Aug 2024 10:33:09 -0300 Subject: [PATCH] LOYALIST-51 Use jQuery for required search invalid event --- .../modules/loyalist_core/js/search_input_required.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) 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);