How to validate textbox to accept only characters in windows form


 Below Coding TextBox Accept only Characters....


  if ((e.KeyChar >= 65 && e.KeyChar <= 90) || (e.KeyChar >= 97 && e.KeyChar <= 122) ||               (e.KeyChar  == 32) || (e.KeyChar == 8))  //keychar 8 is for backspace
            {
                e.Handled = false;

            }
            else
            {
                e.Handled = true;
                MessageBox.Show("Please Enter Character Only...." );
             }

Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

0 comments: on "How to validate textbox to accept only characters in windows form"

Post a Comment