11

Restrict Special Characters in textbox – jQuery

This post shows you how to restrict typing special characters in a text box using jQuery and regular expression.
This script not only restricts typing special characters but also restricts pasting into the text box.

Here is the regular expression for removing and finding special characters in a string.

In this regular expression all special characters are included, if you feel you don’t want to restrict specific characters then you can delete it from that, especially dot and comma.

And here it the entire example script for you to play around with it,

Demo to test it:

demo

 

agurchand

Technologist, software engineer, blogger with experience in Web development and the Media.

11 Comments

  1. Thanks, this is working fine….
    But it allows special character if i paste them from clipboard using right click and paste.

  2. hi,

    I need an event like input box which allows special characters, numbers, all the things.. but not allow only special characters or only numbers…

    can you help on this

Leave a Reply