Hi ashishk,
Check this example. Now please take its reference and correct your code.
Form Design
Code
C#
private void btnMobile_Click(object sender, EventArgs e)
{
if (!System.Text.RegularExpressions.Regex.IsMatch(txtMobile.Text.Trim(), "^[0-9]{10}$"))
{
MessageBox.Show("Enter 10 Digit mobile number");
}
}
private void btnAadhar_Click(object sender, EventArgs e)
{
if (!System.Text.RegularExpressions.Regex.IsMatch(txtAadhar.Text.Trim(), @"^(\d{12}|\d{16})$"))
{
MessageBox.Show("Enter 12 or 16 Digit Aadhar number");
}
}
Screenshot