I want to validate textboxes for various purposes. Like only integers can be entered or only alphabets (capital/small).
How do I do that?
I wrote following code, but it gave me error:
Code: Select all
private void button1_Click(object sender, EventArgs e)
{
Regex r = new Regex("0-9");
if (r.IsMatch(textBox1.Text))
{
MessageBox.Show("Everything is fine", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
return;
}
}
Code: Select all
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
How about validation using ASCII codes. I used to do it when I was doing simple VB 6.0.