Jaya Prakash

Jaya Prakash

  • 548
  • 2.3k
  • 63.4k

Email Validation

Mar 6 2023 11:13 AM

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]$"

 


Answers (2)