Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any jQuery .change realtime alternative? [closed]

I want something to happen right after change has been made in input field, not after this input has been unfocused. Is there any alternative?

DEMO HERE

UPDATE it should be also working for types where user doesn't have to actually click the button in the keyboard (like HTML5 input types=number/date)

like image 655
feri baco Avatar asked May 30 '13 10:05

feri baco


1 Answers

The actual event changes with the type of the control. I put together some examples:

$(document).ready(function() {
    function callback() { alert($(this).val()); }
    $('input[type=number]').on('input',callback);
    $('input[type=date]').on('input',callback);
    $('input[type=text]').on('keyup',callback);
});

NOTE: If you use CTRL+V to paste text, the keyup event might fire twice.

NOTE2: Right click -> Paste won't be recognized. paste event won't help you either, because it fires before the text is updated.

like image 184
Alex Avatar answered Sep 21 '22 06:09

Alex