<!DOCTYPE html>
<html>
<body>
<input type="text" id="txtName" onkeyup="exec(this.value)" />
<script type='text/javascript'>
var timer;
exec = function(textData){
clearTimeout(timer);
timer = setTimeout(function(){ console.log(textData) }, 2000);
}
</script>
</body>
</html>