How to allow only 10 digits using regex?
By James J
Allow only 10 digits as input & validate it using regex...
private void button1_Click(object sender, EventArgs e)
{
System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"^[0-9]{10}$");
if (regex.IsMatch(textBox1.Text))
{
MessageBox.Show("Value is correct.");
}
else
{
MessageBox.Show("Value is not correct.");
}
}
How to allow only 10 digits using regex? (909 Views)