I’m looking to restrict a field to numeric input.
The following neat example from w3schools shows how to achieve the exact opposite of that - blocking only numbers.
I found that removing the exclamation mark (!) on line #19: ([FONT=“Courier New”]return [COLOR=“Red”]![/COLOR]numcheck.test(keychar);[/FONT]) switches it to allowing only numbers. However, as a consequence, such keys as Shift, Ctrl, Home, End, Insert, Delete, Backspace, etc are also blocked, so some of the useful functionalities, e.g. user’s ability to Shift-select are disabled.
Question: How do I modify this code so the input field would accept only numbers without compromising those basic text editing functionalities or the concise elegance of the code.
Thank you much.