1

I wants to stop the search field submission, if my search field is empty or null. can anyone help me that how to do this, or is it possible. because when i am clicking on search button when my search field is empty, EE redirects to me on default error template where showing "You did not submit a search term" , i wants to stop the redirection on this page, can i send it to my any other template when my search field will be empty.

Thanks in advance

4

You have this tagged as PHP, but this sounds more like a job for JavaScript. The Search module is already preventing empty searches, which is why you get that error page. Lots of ways to accomplish this, here is one way if you are using jQuery:

$(document).ready(function() {
    $('#search').submit(function() {    
        if ($('#keywords').val() == '') {
            return false;
        }
    });
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.