This is the regular expression validation to accept numbers only.
Generally I used to validate textboxes that has to take digits as inputs we can specify range too.
The Regular expression is as follows
@"^\d{0,9}$"
This Regular expression is tested and I would really welcome any corrections and suggestions.
The usage is as follows.
private void button1_Click(object sender, EventArgs e)
{
if (Regex.IsMatch(textBox1.Text, @"^\d{0,9}$"))
{
MessageBox.Show("ok");
}
else
{
MessageBox.Show("is not matched");
}
}
This is code snippet for validating textbox value for numbers between range 0 to 9.