0

Basically my WordPress theme's search results page doesn't return a "normal" looking page when no characters are submitted. When you use the search tool properly though and actually type something in, it works just fine.

So instead of looking deeper into this, is there a way to simply disable the search box so it doesn't submit anything unless something has actually been typed in?

Thanks.

user2440477
  • 91
  • 1
  • 4
  • 10
  • but if you go straight to the search page anyway... – Ohgodwhy Jan 17 '14 at 23:11
  • 2
    If you disable the search box, they can't type any characters in (because it is disabled). You want to disable the submit button as AlienArrays is suggesting. – Jonathan Kuhn Jan 17 '14 at 23:14
  • Just use a default search string if nothing is entered that shows what you want to highlight on your site. – jeroen Jan 17 '14 at 23:16

2 Answers2

0

Check this: jquery-placeholder

Shhade Slman
  • 263
  • 2
  • 10
0

This is just a basic form validation thing.

Add something like this to your javascript to prevent submits on empty.

Note: this is incomplete, you'd want to message them with something at this point.

jQuery(document).ready(function($){
    $('#searchform').submit(function _validate(){
        if($('#s').val() == ""){
            return false;
            }
        });
});
mattbeck
  • 135
  • 7