javascript - Word counter function not working with barcode scanner -
javascript - Word counter function not working with barcode scanner -
$("#itemids").keypress(function(){ var value = $(this).val().replace(" ", ""); var words = value.split(","); $("#counter").html(words.length); });
this function works keyboard. when utilize barcode scanner, (i'm focusing cursor on textarea , starts scan barcode textarea delimiters comma.) doesn't work @ all.
i think must other keypress(function() . because bc scanner enters words programmatically. how work both situations: keyboard , bc scanner?
it looks solution use polling, not events.
function update(){ var value = $("#itemids").val().replace(" ", ""); var words = value.split(","); $("#counter").html(words.length); } setinterval(update, 10); // poll every 10ms
javascript jquery function counter
Comments
Post a Comment