.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Jean Paul
SP
satyapriyanayak
ASPEvil
Ashutosh Jha

Home >> Code Snippets >> ADO.NET >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Not Allowed Special Characters and Space in TextBox onkeydown

Posted By:Shashi Ray       Posted Date: March 25, 2009    Points: 10    Category: ADO.NET    URL:   
 

In aspx Page

 

<script type="text/javascript">

 

 

function NotAllowSpace(e){    

var Shashi =(window.event) ? event.keyCode : e.keyCode;         

if (window.event) Shashi = window.event.keyCode;        

if((window.event.shiftKey))       

{                   

if((Shashi > 48 && Shashi < 57))                   

{                   

return false;                   

}                   

else if((Shashi > 96 && Shashi < 105))                   

{                   

return false;                   

}                   

else if((Shashi == 46))                   

{                   

return false;                   

}                   

else if((Shashi == 8))                   

{                   

return false;                   

}                   

else                    

{                   

return false                   

}       

}       

else       

{                       

if((Shashi > 48 && Shashi < 57))                       

{                       

return true;                       

}                        

else if((Shashi > 96 && Shashi < 105))                       

{                       

return true;                       

}                       

else if((Shashi == 46))                       

{                       

return true;                       

}                       

else if((Shashi == 8))                       

{                       

return true;                       

}                        

else if((Shashi == 57))                       

{                        

return true;                       

}                       

else if((Shashi == 48))                       

{                       

return true;                       

}                       

else if((Shashi > 65 && Shashi < 90))                        

{                       

return true;                       

}                        

else if(Shashi==65)                                              

{                        

return true;                       

}                       

else if(Shashi==90)                                              

{                        

return true;                       

}                       

else if((Shashi == 16))                       

{                       

return false;                       

}                       

else                       

{                       

return false;                       

}

 

}           

}

 

</script>

 

<asp:TextBox ID="TextBox1" runat="server" onkeydown="return NotAllowSpace(this);" >asp:TextBox>

 

 

Shashi Ray



     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend