On Change Event withou loosing focus

I have a ASP textbox, that I scan a value into.

I want the form to Postback on the scan, currently I have to tab out of the textbox for the onchange event to fire.

Tried the same with JavaScript with the same result.

Any know how to do this?

Andy
LVL 3
Andy GreenAsked:
Who is Participating?
 
Julian HansenCommented:
What constitutes a completion of entry into an input?

There are only two things I can think of
1. Change focus
2. Timeout

What you can do is implement a script the checks for a keypress / keyup event and starts a timeout. If another keyup event happens before the timeout the timeout is refreshed.
The timeout fires a function that does the post back.
Something like this
<input type="text" name="fred" id="scanme" />

Open in new window

jQuery
<script>
$(function() {
  var timer = false;
  
  $('#scanme').keyup(function() {
    if (timer) {
      clearTimeout(timer);
    }
    timer = setTimeout(function() {
      alert('posting ' + $('#scanme').val());
    },1500);
  });
});
</script>

Open in new window

0
 
Andy GreenAuthor Commented:
Thanks - quite an ingenious solution.
0
 
Julian HansenCommented:
You are welcome.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.