Skip to content
Snippets Groups Projects
Commit 118446e7 authored by Vanessa Wiyono's avatar Vanessa Wiyono
Browse files

add debounce

parent 9310e03d
Branches feat/search
No related merge requests found
......@@ -100,7 +100,7 @@
<?php endif; ?>
<!-- Change input type to "text" for minimum stock -->
<input type="text" name="min_stock" placeholder="Min Stock" value="<?= htmlspecialchars($minStock) ?>">
<button type="submit">Search</button>
<button type="submit" id="search-button">Search</button>
</form>
</div>
......@@ -126,6 +126,24 @@
&copy; 2023 Ticket Ku. All rights reserved.
</div>
</div>
<script>
// disable search button temporarily (DEBOUNCE)
function disableSearchButton() {
const searchButton = document.getElementById("search-button");
searchButton.disabled = true;
setTimeout(() => {
searchButton.disabled = false;
}, 1200); // 0.8s delay
}
document.querySelector(".search-bar form").addEventListener("submit", function (e) {
e.preventDefault();
disableSearchButton();
});
</script>
</body>
</html>
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment