• Resolved Aziz

    (@azizpbrimah)


    Is there a way to make a minimum character limit for the search box? For example, making it that no results are returned unless the 3 or more characters are input. This would prevent results returning/showing for only 1 or 2 characters having been input. Please advise. Thanks.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    I see what you mean, but unfortunately, I’m not aware of a solution for that, sorry.

    Regards,
    Tobias

    Thread Starter Aziz

    (@azizpbrimah)

    Thanks. Do you think this is something that can be implemented in the future?

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    if so, it would not be directly in TablePress, but would have to be in the external DataTables JavaScript library that TablePress uses. It’s not impossible, but I don’t know how big the chances are. Sorry.

    Regards,
    Tobias

    Thread Starter Aziz

    (@azizpbrimah)

    No worries. Hopefully someone else will need this kind of functionality (or may have already needed it, couldn’t find it) and will figure it out. Thanks, again.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    yes, that would be nice! We’ll have to be patient…

    Best wishes,
    Tobias

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    If you are using the Inverted Filter Extension, you could indeed modify it to check the length of the search term, before showing the table. With that, the filtering would still be done in the background, but it would not be shown.
    For this, please try changing the line

    $( '.dataTables_wrapper' ).find( '.tablepress' ).toggle( '' !== $( this ).val() );
    

    to

    $( '.dataTables_wrapper' ).find( '.tablepress' ).toggle( $( this ).val().length > 3 );
    

    Note however that this is only cosmetics and nothing secure at all. A visitor could simply turn off JavaScript in the browser or inspect the source code of the HTML page in the browser and he would be seeing all data of your directory.

    Regards,
    Tobias

    Thread Starter Aziz

    (@azizpbrimah)

    Works perfectly! Thanks so much!

    Thread Starter Aziz

    (@azizpbrimah)

    By the way, I am aware that this is only a cosmetic fix at the moment. We’ve been using TablePress for the directory for over three years now. Until we find another solution, this will have to do. Thanks again!

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! ?? Good to hear that this helped!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

    Thread Starter Aziz

    (@azizpbrimah)

    Consider it done!

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks, I really appreciate it!

    Best wishes,
    Tobias

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Setting a minimum character limit for search’ is closed to new replies.