Stop an Empty Keyword Search

In a ProStores store, a blank keyword search will return "All" products — If you have a large catalog, this is never a good thing. Expecting your users to view 2000 items 25 items at a time is just silly. Here is a quick, easy way to completely remove the possibility of a blank keyword search in your ProStores store.

In Page Template Manager, locate the opening of the default keyword search form found in the Header template source code. It should look something like this:


<form method="post" action="$storeVersion.searchResults"></form>

There is a DOM event called "onSubmit". Using this event, we can easily add a test to the form that will keep the form from being submitted if the keyword input is empty. Example:

onSubmit="if(document.searchForm.keyword.value == '') return false;"

Once you correctly add the event to the form element it should look like this:


<form method="post" action="$storeVersion.searchResults" onSubmit="if(document.searchForm.keyword.value == '') return false;"></form>

Now, with no complicated form validation or any other scripting, your keyword search form cannot be submitted unless the user enters a keyword. That makes sense, right? You're welcome.

About this Entry

This page contains a single blog entry by Eric Anderson published on February 28, 2008 5:56 PM.

ProStores Design Settings: Font Size was the previous entry in this blog.

ProStores v9.0 Sneak Peek is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.