I need your help,
The javascript coding works flawlessly and achieves the desired result, but for some reason, it does not allow the keys on the number pad to typed into the input box. Most users would type in numbers using the numlock keys on the keyboard. How can the coding be modified so as to allow the keys on the seperate number pad on the keyboard to function?
<!DOCTYPE html>
<html>
<body>
<div>
<input type="text" id="rownum">
</div>
<script type="text/javascript">
document.getElementById('rownum').onkeydown = function(e) {
var key = (window.event) ? event.keyCode : event.which;
alert(key);
if (key == 8) { // Delete key
return
}
else {
if ( isNaN( String.fromCharCode(key) ) ) return false;
}
}
</script>
</body>
</html>