on the emailtextbox validating events
private void Email_Validating(object sender, CancelEventArgs e)
{
System.Text.RegularExpressions.Regex rEMail = new System.Text.RegularExpressions.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.Text.Length > 0)
{
if (!rEMail.IsMatch(Email.Text))
{
MessageBox.Show("invalid email address", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Email.SelectAll();
e.Cancel = true;
}
}
}
private void Email_Validating(object sender, CancelEventArgs e)
{
System.Text.RegularExpressions.Regex rEMail = new System.Text.RegularExpressions.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.Text.Length > 0)
{
if (!rEMail.IsMatch(Email.Text))
{
MessageBox.Show("invalid email address", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Email.SelectAll();
e.Cancel = true;
}
}
}
No comments:
Post a Comment