Reputation: 89
I have a text input and a handler routine testFunc(input.value)
testFunc should be called when
I tried with onkeypress and onkeyup, but some how testFunc handler routine is not getting with the updated value (or) testFunc routine itself is not getting called.
Can any one let me know how i can resolve this issue or whether there is any existing APIs in Javascript
Upvotes: 0
Views: 8545
Reputation: 324567
You can use the HTML5 input
event, which is fired whenever the input value changes, and fires after the value has changed. In combination with an IE workaround, it's surprisingly compatible. See the following answer:
Upvotes: 3
Reputation: 147373
In which browsers? The following always shows the current value of the input whenever a key is pressed:
<script type="text/javascript">
function show(s) {
document.getElementById('msg').innerHTML = s;
}
</script>
<input type="text" onkeyup="show(this.value);">
<div id="msg"></div>
Upvotes: 0