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 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

$(function() {
  var timer = false;
  $('#scanme').keyup(function() {
    if (timer) {
    timer = setTimeout(function() {
      alert('posting ' + $('#scanme').val());

Open in new window

Andy GreenAuthor Commented:
Thanks - quite an ingenious solution.
Julian HansenCommented:
You are welcome.
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.