Prohibit searching with empty search term and taxonomies

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Prohibit searching with empty search term and taxonomies

This topic contains 1 reply, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 9 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #45392
    Monolab
    Monolab
    Participant

    Dear Ernest,

    We have a search form with search box and a few taxonomies.
    I want to show an error message when user clicks Search button (or presses Enter) if all of this are true: (form is empty)
    – search box is empty
    – no checkbox is selected
    – no option is selected from any of the dropdowns

    The see the current version:
    Open https://hd.devsite.hu
    Top right corner, the small magnifier icon will open the popup with ASP

    Expected behaviour:
    1. Open https://www.nigella.com
    2. Click the magnifier icon in the top right corner
    3. Leave the form empty
    4. Click Search
    5. An error message will appear just below the search box saying “Please enter a search term or select a filter.”

    1. I have tried with asp_search_start Javascript hook, but i was unable to abort searching. Can it be done in that hook?
    2. Is there any easy way to check from JS if the form is empty? If not, I can still solve with jQuery, the important question is the previous one

    Thanks in advance

    #45398
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    For the filters there are options to do that here: https://i.imgur.com/0iwGFOI.png

    For the search input there is no such feature, however you can set the minimum character count to trigger from 0 to 1 or higher here: https://i.imgur.com/baosD8O.png
    Unfortuantely that is not going to display a message. However with that the search is not triggering so you don’t need to abort. Then you could hook an event listener and check for the length with for example: jQuery('.asp_m input.orig').val().length

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.