JavaScript: mask for numbers that allows arrows/pgup/pgdown etc
<p>I've written simple JavaScript mask that allows you to write only numbers to input. But the thing is, when you press arrow key, the <strong><em>caret will move back to the end of the line</em></strong>.</p>

<p>How can I ignore arrow keys, or other meta keys?</p>

<p>Here's my mask:</p>

<pre><code>function applyMaskInteger(elementId) {
    var e = document.getElementById(elementId);
    e.value = e.value.replace(/[^0-9]/g,"");
}
</code></pre>

<p>PS: I like jQuery, but please answer only with plain JavaScript ... (we don't use jQuery on this project)</p>
