How would you go about Restricting Keyboard Input on a textbox using Jquery?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you don’t want the user to be able to type anything in the text-box, then consider the
readonlyanddisabledattributes. If the data in the textbox is needed at the server side, make itreadonly. If not, make itdisabled.If you want the user to be able to type in something, but only restrict certain types of characters such as numbers only, then listen to the
keyupevent on the textbox. It is fired whenever a key is released inside the text box. On this events callback, check the value of the textbox, and make changes to the value as necessary.