Here are 3 ways of fixing this, I advise you use solution 2, but pay attention to the jQuery in solution 1 as a way of avoiding the situation in the first place.
For those wanting more code posted from the question askers theme, this is not a theme issue, this is a general WordPress issue that affects all WordPress sites.
Solution 1
You can find an in depth tutorial on how to fix this here:
http://wpengineer.com/2162/fix-empty-searches/
Today, let’s look at something, that most professionals never see:
empty searches. You offer a search input field, and someone hits the
submit button unintentionally, without any term entered. The resulting
URI looks like this: example.com/?s=. It shows the same content as
your front page. In fact, it is the front page.No one needs that.
Solution 2 (recommended)
Taken froma post by Spitzerg http://wordpress.org/support/topic/blank-search-sends-you-to-the-homepage
Another option is to add a request filter:
add_filter( 'request', 'my_request_filter' ); function my_request_filter( $query_vars ) { if( isset( $_GET['s'] ) && empty( $_GET['s'] ) ) { $query_vars['s'] = " "; } return $query_vars; }
Then if you’re reusing the search query in your search form don’t
forget to trim it so you don’t end up with one or more spaces (just to
keep things clean, probably won’t affect results.
<input type="text" name="s" id="s" value="<?php echo trim( get_search_query() ); ?>"/>
Hope this helps, it seems to be working thus far on my site and
doesn’t involve changing any of the WP code making upgrades easier.
Solution 3
http://www.warpconduit.net/2011/08/02/fix-redirection-and-error-page-on-empty-wordpress-search/
Similar to solution 2 but not as extensive and slightly different.
if(!is_admin()){
add_action('init', 'search_query_fix');
}
function search_query_fix(){
if(isset($_GET['s']) && $_GET['s']==''){
$_GET['s']=' ';
}
}