TextBox takes input only letters
Hi, I have a problem while taking input in textbox that it takes input all characters. I want it to take only letters(caps and small both) as input.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Charith LiyanagamagePosted Jun 20, 2009, 2:03 PM
//Function
public static bool IsDigit(string tcString)
{
//get the first character in the string
char c = tcString[0];
return Char.IsDigit(c);
}
//button_click event
private void button1_Click(object sender, EventArgs e)
{
char[] letters=new char[50];
int len = textBox1.Text.Length;
for (int j = 0; j < len; j++)
{
letters[j] = Convert.ToChar(textBox1.Text.Substring(j, 1));
}
for (int i = 0; i < len; i++)
{
bool result = IsDigit(letters[i].ToString());
if (result == true)
{
MessageBox.Show(letters[i]+"is a digit");
}
}
}
if you need any clarification regarding above code please write to me......
Charith LiyanagamagePosted Jun 24, 2009, 1:06 PM
Neetu GoswamiPosted Jun 21, 2009, 3:30 AM