using System.Text.RegularExpressions;
private void TxtEmail_Leave(object sender, EventArgs e)
{
if (TxtEmail.Text == "")
return;
Regex EMail = new Regex(@"^[a-zA-Z][\w\.-]{2,28}[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$");
if (!EMail.IsMatch(TxtEmail.Text))
{
MessageBox.Show("Invalid Email ID", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
TxtEmail.Focus();
}
}
No comments:
Post a Comment