By default, an empty search in Divi will result in the display of all posts on the search page. Here's how to prevent empty searches.
Prevent Empty Searches in the Default Header Search Box
To prevent empty searches in the search box revealed by the search icon in the main Divi header, you can use the following jQuery code:
<script>
jQuery(
function($){
$('.et-search-field').prop('required',true);
}
);
</script>
Related Post: Adding JavaScript / jQuery to Divi.
This will notify the user that the field must be filled in, like so:
Prevent Empty Searches in the Divi Search Module
To prevent empty searches in the search box added by a Divi search module, you can use the following jQuery code:
<script>
jQuery(
function($){
$('.et_pb_search .et_pb_s').prop('required',true);
}
);
</script>
Related Post: Adding JavaScript / jQuery to Divi.
0 Comments