From 6e4d7250188934599ef4abf37caf50005199cc68 Mon Sep 17 00:00:00 2001 From: Fabian Schieder Date: Mon, 30 Mar 2026 19:53:55 +0200 Subject: [PATCH] Update search term validation to allow single character input in compcards.php, search-autocomplete.js, and search_products.php --- api/search_products.php | 2 +- assets/js/search-autocomplete.js | 4 ++-- compcards.php | 8 -------- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/api/search_products.php b/api/search_products.php index 22b6e8d..616052d 100644 --- a/api/search_products.php +++ b/api/search_products.php @@ -24,7 +24,7 @@ try { } // Minimum query length to reduce load/noise - if (mb_strlen($q, 'UTF-8') < 2) { + if (mb_strlen($q, 'UTF-8') < 1) { echo json_encode(['items' => []], JSON_UNESCAPED_UNICODE); exit; } diff --git a/assets/js/search-autocomplete.js b/assets/js/search-autocomplete.js index 565b731..ea1da7c 100644 --- a/assets/js/search-autocomplete.js +++ b/assets/js/search-autocomplete.js @@ -147,7 +147,7 @@ var debounced = debounce(function () { var q = (input.value || '').trim(); - if (q.length < 2) { + if (q.length < 1) { close(); return; } @@ -158,7 +158,7 @@ input.addEventListener('focus', function () { var q = (input.value || '').trim(); - if (q.length >= 2) { + if (q.length >= 1) { fetchResults(q); } }); diff --git a/compcards.php b/compcards.php index 211f545..081bc84 100644 --- a/compcards.php +++ b/compcards.php @@ -20,14 +20,6 @@ $conn = db_connect(); $searchTerm = isset($_GET['search']) ? trim((string)$_GET['search']) : ''; $searchLen = function_exists('mb_strlen') ? mb_strlen($searchTerm, 'UTF-8') : strlen($searchTerm); if ($searchTerm !== '') { - if ($searchLen < 2) { - ?>
-

Suchergebnisse für „

-

Bitte geben Sie mindestens 2 Zeichen ein.

-