Soren Winslow
Email Validator Function
This function checks for just about anything I can think of for an email address to not be a valid formatted email address short of pinging the domain or sending an actual email and it returns a simple true or false.

Here is the ASP code for this script:
    
  <form name="CheckEmailAddr" method="post" action="<%=Request.ServerVariables("URL")%>">
  Enter your email address:
  <input name="EmailAddr" type="text" size="20" class="bnotes">
  <input type="submit" value="Validate" class="bnotes">
  </form>


  <%
  If Len(Trim(Request("EmailAddr"))) > 0 Then

     Function ValidEmail(EmailAddress)
        EmailAddress = Trim(EmailAddress)
        ValidEmail = True

        'Check for spaces
         If Instr(1,EmailAddress," ") > 0 Then
            ValidEmail = False
         End If

         'Check length. Shortest an address can be is 6 (S@S.com = 7, S@S.cx = 6)
         If Len(EmailAddress) < 6 Then
            ValidEmail = False
         End If

         'Check for only one @ somehere in the middle
          TempArr = Split(EmailAddress,"@")
          If UBound(TempArr) <> 1 Then
             ValidEmail = False
          Else
             For x = 0 to UBound(TempArr)
                If Len(Trim(TempArr(x))) = 0 OR IsNull(TempArr(x)) = True Then
                   ValidEmail = False
                End If
             Next
          End If

         'Check for period either three or four places from end
         If InstrRev(EmailAddress,".") = 0 Then
            ValidEmail = False
         Else
            If Len(EmailAddress) - InstrRev(EmailAddress,".") > 3 OR _
               Len(EmailAddress) - InstrRev(EmailAddress,".") < 2 Then
                 ValidEmail = False
            End If
         End If

     End Function

     If ValidEmail(Request("EmailAddr")) = True Then
        Response.Write "The email address you entered appears to be a " & _
                       "valid email address"
     Else
        Response.Write "The email address you entered " & _
                       "does not appears to be a " & _
                       "valid email address"
     End If

   End If

  %>

    

Enter your email address:
© 1967 - 2008 Soren Winslow