0

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?

Moppo
  • 18,797
  • 5
  • 65
  • 64
Marco Evasi
  • 441
  • 2
  • 14
  • 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 Answers1

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