Issue at Hand:
- The challenge is to restrict allowed characters in an HTML input field to only a-z and A-Z.
- It is essential for business requirements that this restriction happens on KeyPress, preventing disallowed characters from even appearing in the input.
- Tab, Enter, arrows, backspace, and shift should all be permitted. Users must have the ability to freely navigate within the textbox, delete characters, etc.
This marks the beginning of my code...
var keyCode = (e.keyCode ? e.keyCode : e.which);
However, each value obtained in keyCode does not match any character charts found online. For instance, the character "h" results in a keycode of 104.
Are KeyCode and CharCode distinct? Which one includes control characters? Is conversion necessary?
How can I use JavaScript to limit input to a-z and A-Z while allowing the necessary keys?