Results 1 to 3 of 3

Thread: Email Validation

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    97

    Email Validation

    Hi, I need to be able to check if a email address is a valid email so people can't just type in stuff like "jfsajfsajk_jsdljdal".

    My code:

    If System.Text.RegularExpressions.Regex.IsMatch(Trim(txtEmail.Text), "^[a-zA-Z0-9]@{a-zA-Z0-9][\w\.-]*[a-zA-Z][a-zA-Z]*[a-zA-Z]$") = False Then

    lblFeedback.Text = "Please enter a valid Email Address before submitting"
    lblFeedback.ForeColor = Drawing.Color.Red

    End If

    But this isn't working for me, can you see where I went wrong.


    Thanks.

  2. #2
    Hyperactive Member koolprasad2003's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    443

    Arrow Re: Email Validation

    try out this

    "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"

    OR

    ".+@.+\\.[a-z]+"


    Thankx
    Koolprasad2003
    MCP, MCTS, Microsoft MVP [Asp.Net/IIS]

    For more .NET development tips visit .NET Tips

    If the post is useful then please Rate it

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    97

    Re: Email Validation

    that worked great, thanks mate.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width