Reputation: 82
I've this input in a search modal used to find products by Id or Description in this system I'm working:
<input class="input-xlarge" type="text" onkeypress="productsDescription(this.value);">
And in my javascript I have this function
function productsDescription(val) {
alert(val);
}
It happens that when I press a key inside this input, the alert function shows me the value as it was BEFORE the key was pressed. Is there a way to capture the valeu AFTER the key?
Upvotes: 1
Views: 662
Reputation: 14820
Use the onkeyup
event instead the onkeypress
happens BEFORE the value gets changed
<input class="input-xlarge" type="text" onkeyup="productsDescription(this.value);">
Upvotes: 1