Worpress empty search or wordpress search


add_filter( 'posts_search', function( $search, \WP_Query $q )
{
    if( ! is_admin() && empty( $search ) && $q->is_search() && $q->is_main_query() )
        $search .=" AND 0=1 ";

    return $search;
}, 10, 2 );

add_filter( 'posts_search', function( $search, \WP_Query $q )
{
   if( ! is_admin() && empty( $search ) && $q->is_search() && $q->is_main_query() )
      $search .=" AND 0=1 ";
   return $search;}, 10, 2 );
 
<div class="search-toggle"><i class="fa fa-search"></i><a href="#search-container" class="screen-reader-text"> <?php _e( 'Search'); ?> </a> </div> 
 
<div id="search-container" class="search-box-wrapper hide">
   <div class="search-box">
      <div class="container">
         <?php get_search_form(); ?>
      </div>
   </div>
</div>
 
//Hide search form on click some selectors$('.search-toggle').click(function(e) {
    var search_wrapper_element = $( '.search-box-wrapper' );
    if((search_wrapper_element.is(':visible'))) {
        search_wrapper_element.addClass( 'hide' );
        $( '.search-toggle' ).removeClass( 'active' );
    } else {
        search_wrapper_element.removeClass( 'hide' );
        $( '.search-toggle' ).addClass( 'active' );
    }

}); 
 
 $('#search-container .search-form').bind('submit',function(){
        if($(".search-field").val() == '') {
            alert('Please enter something');
            return false;
        } else {
            return true;
        }
    });