Email Validation

Discussion in 'ASP .Net' started by Kiran B., Dec 17, 2004.

  1. Kiran B.

    Kiran B. Guest

    Hi, how can I validate the fomat for valid email and the most important is
    if that email is real working email...sort of checking mx record? How can i
    do this in asp.net

    Thanks in advance....

    KB
     
    Kiran B., Dec 17, 2004
    #1
    1. Advertising

  2. Kiran B.

    vMike Guest

    "Kiran B." <> wrote in message
    news:...
    > Hi, how can I validate the fomat for valid email and the most important is
    > if that email is real working email...sort of checking mx record? How can

    i
    > do this in asp.net
    >
    > Thanks in advance....
    >
    > KB
    >
    >

    I use the following. I am sure there are other ways but it works for me.
    <asp:RegularExpressionValidator id="RequiredEmail1" runat="server"
    ControlToValidate="Email1"
    InitialValue=""

    ValidationExpression="^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|
    (([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"
    Display="Static"
    Font-Name="verdana" Font-Size="10pt">
    * valid e-mail address required
    </asp:RegularExpressionValidator>
    <asp:CustomValidator id="CustomValidator1" runat="server"
    ControlToValidate="Email1"
    OnServerValidate="ServerValidate"
    Display="Static"
    Font-Name="verdana" Font-Size="10pt">
    * valid mail server name required.
    </asp:CustomValidator>

    My code for validating the server name is

    Sub ServerValidate (sender As Object, dnsvalue As ServerValidateEventArgs)
    dim strDomain as string
    dnsvalue.IsValid = False
    Try
    dim int as int32
    int = instr(2,dnsvalue.Value,"@")
    strDomain = mid(dnsvalue.value,int+1,999)
    If not Dns.GetHostByName(strDomain).hostname is null Then
    dnsvalue.IsValid = True
    End If
    Catch
    End Try
    RequiredEmail1.text = ""
    End Sub
     
    vMike, Dec 17, 2004
    #2
    1. Advertising

  3. Daniel M. Hendricks, Dec 17, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter
    Replies:
    0
    Views:
    3,379
    Peter
    Jul 1, 2003
  2. John Silver
    Replies:
    0
    Views:
    617
    John Silver
    Feb 4, 2005
  3. Tee

    Email ErrorPage to email

    Tee, Jun 23, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    383
  4. Replies:
    3
    Views:
    536
    AdamM
    Jul 27, 2004
  5. Chuck Amadi
    Replies:
    2
    Views:
    404
    chuck amadi
    Jun 6, 2004
Loading...

Share This Page