This validation is working only when i remove @ or . from the mail when i changed to com to hom,jom anything it is accepting how to correct this validation..
bool isEmail = Regex.IsMatch(TextBox4.Text.Trim(), @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"); if (!isEmail) { lblerrormsg.Text = "Enter Valid Email ID.."; lblerrormsg.ForeColor = System.Drawing.Color.Red; return; } else { lblerrormsg.Text = "Valid Email"; lblerrormsg.ForeColor = System.Drawing.Color.Green; }
i used this one also
@"^[a-zA-Z][\w\.-]{0,68}[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"