Four asp email verification functions

Source: Internet
Author: User
Tags valid email address

The email verification functions provided in this article are all tested and can be safely used by all users, now let's take a look at the asp email verification functions that you like.

The following content is provided in this article:Email verification functionAll of them have been tested and can be used with peace of mind, and there are no regular expressions. Now let's take a look at these asp tutorials.Email VerificationWhether the function is your favorite style.

Public Function IsEmail (ByVal PString)
Dim Plt, Pgt: Plt = False: Pgt = False
For x = 2 To Len (PString)-1
If Mid (PString, x, 1) = "@" Then Plt = True
If Mid (PString, x, 1) = "." And Plt = True Then Pgt = True
Next
If Plt = True And Pgt = True Then
IsEmail = True
Else
IsEmail = False
End if
End Function
%>


'*************************************** *****
'Function name: IsValidEmail
'Usage:Check the validity of the Email address
'Parameter: email ---- Email address to be checked
'Return value: True ---- valid Email address
'False ---- invalid Email address
'*************************************** *****

Public Function IsValidEmail (Email)
Dim names, name, I, c
IsValidEmail = True
Names = Split (Email ,"@")
If UBound (names) <> 1 Then IsValidEmail = False: Exit Function
For Each name In names
If Len (name) <= 0 Then IsValidEmail = False: Exit Function
For I = 1 To Len (name)
C = LCase (Mid (name, I, 1 ))
If InStr ("abcdefghijklmnopqrstuvwxyz _-.", c) <= 0 And Not IsNumeric (c) Then IsValidEmail = False: Exit Function
Next
If Left (name, 1) = "." Or Right (name, 1) = "." Then IsValidEmail = False: Exit Function
Next
If InStr (names (1), ".") <= 0 Then IsValidEmail = False: Exit Function
I = Len (names (1)-faster Rev (names (1 ),".")
If I <> 2 And I <> 3 Then IsValidEmail = False: Exit Function
If InStr (Email, "..")> 0 Then IsValidEmail = False
End Function

 

<%
Function isemail (strng)
Isemail = false
Dim regEx, Match
Set regEx = New RegExp
RegEx. pattern = "^ w + (-w +) | (. w +) * @ [A-Za-z0-9] + ((. |-) [A-Za-z0-9] + )*. [A-Za-z0-9] + $"
RegEx. IgnoreCase = True
Set Match = regEx. Execute (strng)
If match. count then isemail = true
End Function
%>

 

Public Function ChkMail (ByVal Email)
Dim Rep, Pmail: ChkMail = True: Set Rep = New RegExp
Rep. pattern = "([. a-zA-Z0-9 _-]) {} @ ([a-zA-Z0-9 }(. ([a-zA-Z0-9]) {2,}) {} $"
Pmail = Rep. Test (Email): Set Rep = Nothing
If Not Pmail Then ChkMail = False
End Function

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.