enb081
enb081

Reputation: 4051

Jquery ontextchanging Event

Is there anyway I can call a function when the text of a TextBox is being changed?

The function change will work only after the textbox has lost his focus. I need something similar to the keyup function:

$('.TextBox1').keyup(function(e) {
            setTimeout(function() {
            //
            }, 100);
        });

But, this function will only be called if the data is being filled through keyboard, and i need a more general solution. Some cases are:

  1. User types the data via keyboard
  2. User pastes data he copied before
  3. User double clicks the TextBox and selects one of the values from the browser autocomplete menu.
  4. The user drags text from some part of the website and drops it into the TextBox
  5. Barcode scanner
  6. ??? (Any other way to fill in the TextBox I cannot think of)

Is there any Jquery "ontextchanging" event?

Upvotes: 0

Views: 982

Answers (2)

enb081
enb081

Reputation: 4051

I found the answer:

function monitor() {
    // Your code
}

var timer = '';

$('.TextBox1').on('focus', function() {
    timer = setInterval(monitor, 100);
}).on('blur', function() {
    clearInterval(timer);
});

It basically monitors TextBox1 every 0.1 second while it is focused. This is what I was looking for.

Upvotes: 0

SRy
SRy

Reputation: 2967

$('input').bind('keyup keypress blur change cut copy paste ', function() {
   setTimeout(function() {
        alert('here');
        }, 100);

});

Drag and Drop Example :http://jsfiddle.net/5DCZw/2/

Upvotes: 3

Related Questions