Indra Kumar S

Indra Kumar S

  • NA
  • 25
  • 47k

regards validation in phone number

Aug 10 2015 6:46 AM
Hi i am using following code for phone number validations, after 10 digits it will display error message  "Please enter only 10 digits"  but after 10 digits if we enter number means it will add number  so please help me this textbox must not add number after 10 digits.
 
 
private void txtcontactno_TextChanged(object sender, EventArgs e)
{
if (System.Text.RegularExpressions.Regex.IsMatch(txtcontactno.Text,@"^([0-9]{1,10})$"))
{
//MessageBox.Show("match pattern");
// Do something here
}
else
{
MessageBox.Show("Please enter only 10 digits");
txtcontactno.Focus();
}
}
 

Answers (5)