I use Atomz search to allow users to search my site and the weekly report always has the same top query. It is (drum roll please):
blank query
I have no idea why someone would search for nothing, because you get just that as a result, but search for nothing they did.
I decided to put a stop to it. In the header I added a Javascript function that checks the value of the search field and if blank, pops up a message asking the user to please enter a search phrase. Here’s the code to do that.
<script type="text/javascript" language="Javascript">
//<!--
function validateSearch()
{
if ( document.search.sp_q.value == "" )
if ( document.search.sp_q.value.match( /^\s*$/ ) != null )
{
alert( "Please enter a search phrase" );
return false;
}
return true;
}
//-->
</script>
The Javascript method is executed when the user hits the search button by adding the bold text.
<form name="search" method="get" action="http://search.atomz.com/search/"
onSubmit="return validateSearch();">
<input type=text size=30 name="sp_q"><br>
<input type=submit value="Search this site">
</form>
Blank queries still show up occasionally, but they’re probably from users who have Javascript disabled. An even better solution would be for the server to make sure the search isn’t blank too, but since I don’t have access to the server-side code, this is the best I can do.