Let the user input only alphabet and numbers

While designing the FORM, the designer wants to force the user to input only alphabet and numbers For example , in a User Name input field, the user dont need to press $,# ,%,{,},[,] etc keys while while entering data. Therefore, if the form is designed in the way, that if users  intentionally or unitentionally press those Keys, it will not refelect in the textbox. Now, how can we do that,

A simple javascript using regular expression we can do that in “onkeypress” or “onkeydown” event .

To know more with a live demonstration, you can go to this link,


If you find any difficulties or if you know more better aprroach, share it here.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s