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

Top 5 Contributors of the Month
Gaurav Pal

Home >> Code Snippets >> Validations >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Restrict User to write any other words except digit in Textbox

Posted By:Ravi Ranjan Kumar       Posted Date: June 29, 2011    Points: 40    Category: Validations    URL: http://www.dotnetspark.com  

This article enable you to learn how to restrict user to write any thing except digit.

By using given code you can restrict user to write any thing except digits 
if (!(e.KeyChar >= '0' && e.KeyChar <= '9'))
                e.Handled = true;
alternative tips
if (!char.IsDigit(e.KeyChar))
               e.Handled = true;


Further Readings:


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