How to just show front page and message when search api search was queried with blank input How can I just show front page when no letters were printed in search input, but it was submitted?

And optionally maybe show message 'please enter the terms of the search'

I thought of doing this with Rules, but no rules considering searches are present(
Here is a solution:

function MY_THEME_form_alter(&amp;$form, &amp;$form_state, $form_id) {

  if($form_id == 'search_block_form' || $form_id == 'search_form') {
    array_unshift($form['#validate'], 'custom_search_validate');
  }
}

function custom_search_validate($form, &amp;$form_state) {
  dpm($form_state);
  if(isset($form_state['values']['search_block_form']) &amp;&amp; $form_state['values']['search_block_form'] == FALSE) {
    drupal_set_message('please enter the terms of the search', 'error');
    drupal_goto();
  }

  if(isset($form_state['values']['keys']) &amp;&amp; $form_state['values']['keys']
    == FALSE) {
    drupal_set_message('please enter the terms of the search', 'error');
    drupal_goto();
  }
}