Skip to content
Advertisement

JQuery to allow only alphabets, numeric and forward slash in TextBox

I have a text field in ASP.NET and i want to allow only alphanumeric and forward slash (/) keys in that. I tried the following code,

JavaScript

In the web forms page i added like below,

JavaScript

Here i am able to enter alphabets and numbers but i am not able to enter the value /. I have enabled the shift key so i can give shift + ? to enter the forward slash. Also another problem is when i press shift + any numeric key the special characters there like ! @ # $ % ^ & * ( ) ... are also coming in tet field. What am i doing wrong here?

Advertisement

Answer

SOLUTION

Finally found a solution as below,

JavaScript

This code works perfectly!!

Advertisement