javascript onkeypressed not giving current text box content
- by Austin
I have an html form like this:
<form id="boxy" action="layout.html" method="get" accept-charset="utf-8">
<input type="text" id="a" onkeypress="Boxy.Check(this);">
</form>
Invoking javascript like this:
Boxy.Check = function() {
input = document.getElementById(this.currentSelector.id).value;
console.log("\"" + input + "\"");
};
However, this.value is the previous value before onkeypress.
For example, if I just type "A" into the form, console.log() prints "". And if I type "AA", console.log prints "A".
Is there a way to get the current content of the input?