In the jQuery DataTables example of Custom filtering - range search if I enter a value, example "41" in the input field Maximun age, the table gets updated just after I click the first number (the "4"), and this way all the rows disappear until I the also digit the second number (the "1"). Is there a way to wait to update the table untill the second number is digited (let's assume that we don't want numbers less than 10)? Is it possible even to update just if I click enter?
Asked
Active
Viewed 626 times
0
-
check [here](http://stackoverflow.com/questions/5548893/jquery-datatables-delay-search-until-3-characters-been-typed-or-a-button-clicke) – Moppo Jun 10 '15 at 20:24
1 Answers
1
try this:
$(document).ready(function() {
var table = $('#example').DataTable();
// Event listener to the two range filtering inputs to redraw on input
$('#min, #max').keypress( function(event) {
var max = parseInt( $('#max').val(), 10 );
if(event.which!==13 || max<10)
return;
table.draw();
} );
} );
I replace keyup for keypress and capture the key 13 (enter). When the user press enter or max value is less than 10, dont draw the table.
see http://jsfiddle.net/andresrondan/gygskjgx/
hope this helps

Andrés Rondán Mulero
- 370
- 2
- 10
-
Thanks it helps. Just one more case: if my field value are dates should I use this approach (I think it works: >999 if I want to enter YYYY), or is it a better way? – Marco Evasi Jun 10 '15 at 20:58
-
Thanks! I dont know the context of your application but filter >999 seems a good solution. ;) – Andrés Rondán Mulero Jun 10 '15 at 21:05