Update search term validation to allow single character input in compcards.php, search-autocomplete.js, and search_products.php
This commit is contained in:
parent
02d33fd194
commit
6e4d725018
@ -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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
@ -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) {
|
||||
?><section class="product-section">
|
||||
<h2>Suchergebnisse für „<?= htmlspecialchars($searchTerm) ?>“</h2>
|
||||
<p class="search-empty">Bitte geben Sie mindestens 2 Zeichen ein.</p>
|
||||
</section><?php
|
||||
return;
|
||||
}
|
||||
|
||||
$like = addcslashes($searchTerm, "%_\\");
|
||||
$like = '%' . $like . '%';
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user