I will share the source code of allowing only text in input type text onkeypress example. In this example, when a user will be typing, then we will accept only text from input field. If you don't know that way then follow the source code.
Example code of html input text only letters:
Hope it can help you.