1
add reference od system.text.regularexpression
and then use this code:
private void txtEmail_Leave(object sender, EventArgs e)
{
Regex mRegxExpression;
if (txtEmail.Text.Trim() != string.Empty)
{
mRegxExpression = new Regex(@"^([a-zA-Z0-9_\-])([a-zA-Z0-9_\-\.]*)@(\[((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}|((([a-zA-Z0-9\-]+)\.)+))([a-zA-Z]{2,}|(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\])$");
if (!mRegxExpression.IsMatch(txtEmail.Text.Trim()))
{
MessageBox.Show("E-mail address format is not correct.", "MojoCRM", MessageBoxButtons.OK, MessageBoxIcon.Error);
txtEmail.Focus();
}
}
}
thanks
Please mark as answer if it helps
Accepted 0
The information which u gave was very helpful...thanks a lot...
0
hello Shivraj
Regular expressions provide a powerful, flexible, and efficient method for processing text.
in above regular expression we can check input email id text format.
check this article on msdn:
http://support.microsoft.com/kb/308252thanks
0
if u dont mind can u give explanation for d below code...thank u...
mRegxExpression = new Regex(@"^([a-zA-Z0-9_\-])([a-zA-Z0-9_\-\.]*)@(\[((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}|((([a-zA-Z0-9\-]+)\.)+))([a-zA-Z]{2,}|(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\])$");