Search Behavior When No Query Is Entered

How can we add a short instruction instead of displaying all records when the user presses Enter/Return without entering a query in the search field?

Search element in Bricks Builder v2.4.2

I don’t want to use the Livesearch of Filter-Search.

You can make the Search element’s field required, so an empty Enter press stays on the page and prompts the visitor to enter a search term. Add this JavaScript to the page or template’s custom code:

document.querySelectorAll('.bricks-search-form input[name="s"]').forEach((input) => {
  input.required = true;
});

The browser will show its built-in required-field message. This applies to every Bricks Search form on that page and does not require Filter Search.

Hi timmese,

Thank you for providing the JavaScript to implement the search query. I’ve implemented the script, and it’s working perfectly!

Really appreciate your quick assistance and the effective solution. Thanks again for your help!