DataTables Search Filter Exact Match

DataTables Search Filter Exact Match

KeiSenpaiKeiSenpai Posts: 21Questions: 8Answers: 0

Hello All,

I am new to DataTables and wondering is it possible to make the search box filter for exact match only?
I know at the moment if I have a list of numbers, and type '1', it will pull back anything containing '1'.

I appreciate it.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954
    Answer ✓

    You will want to use regex searching. See this example. Your search string, for the 1 example you gave, will need to be ^1$. The use can type ^1$ or you can create a custom input where the user types 1 and you insert the value between ^ and $, for example table.search( '^' + $('#myInput').val() + '$' ).draw();.

    Kevin

This discussion has been closed.