How to set maxlength for the filter criteria?

How to set maxlength for the filter criteria?

plasmerplasmer Posts: 3Questions: 0Answers: 0
edited February 2013 in General
I just found out that in current version of Datatable, the filter can take as many characters as you want. I am wondering how to set a upper limit for the input? For example, I just want a user be able to enter 50 characters(including space) at most into the filter textbox, how can I make that happen? Thank you!

Replies

  • hydradictyhydradicty Posts: 5Questions: 0Answers: 0
    edited March 2013
    The following procedures worked for me, try with caution!

    * Open file media/js/ jquery.dataTables.js
    * replace all cases of


    with



    Save and close file.

    That is it.

    - Hydradicty
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Or a line of jQuery after you initialise your table:

    [code]
    $('.dataTables_filter input').attr( 'maxlength', 50 );
    [/code]

    Allan
  • plasmerplasmer Posts: 3Questions: 0Answers: 0
    @hydradicty thank you, but I don't want to modify the js file whenever the datatable get updated, but I have found a way to do it in code.
  • plasmerplasmer Posts: 3Questions: 0Answers: 0
    @allan thanks, this is the way I found as well, it works good.
This discussion has been closed.