Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am doing the application in windows forms..
i need the following requirement in the textbox

In my TextBox i want to allow only numbers and chars and UnderScore Spl Symbol only..
remaning all spl symbols i want to restrict in windows Forms..

How i can do this?..

If u know help me..

Thanks & Regrads
Honey
Posted

You can add regular expressions
http://msdn.microsoft.com/en-us/library/ms229603.aspx[^]
 
Share this answer
 
Try this one

C#
function Alpha()

{

var key=window.event.keyCode;

if

((key > 64 && key < 91)||(key > 96 && key < 123)||(key > 47 && key < 58)||(key==95))

return;

else

window.event.returnValue=null;

}
 
Share this answer
 
Comments
honey4bee 13-Oct-11 2:17am    
Hi Simple,
in "var key=window.event.keyCode;" when i am typing that "window" is not showing in intelligency..
can i add any namespace for that?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900