1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| private void textboxEmail_Validating(object sender,
System.ComponentModel.CancelEventArgs e)
{
Regex emailregex = new Regex("(?[^@]+)@(?.+)");
Match mmatch = emailregex.Match(this.textboxEmail.Text);
if ( mmatch.Success )
{
MessageBox.Show("UserName: " +
mmatch.Groups["user"].Value+"\n"+"HostName: " +
mmatch.Groups["host"].Value,"E-Mail Information");
this.statusBar1.Text=""; //efface barre de statut
}
else
{
MessageBox.Show("invalid e-mail address...","E-Mail Information");
e.Cancel=true; // ne pas quitter la saisie pour la corriger
}
} |
Partager