Common ASP + VBScript judgment Functions

Source: Internet
Author: User

Function isvalidqqnumber (qqstring)
'Determine the QQ number format
Isvalidqqnumber = true

If Len (qqstring) <5 or Len (qqstring)> 12 then
Isvalidqqnumber = false
Else
For I = 1 to Len (qqstring)
Testchar = lcase (mid (qqstring, I, 1 ))
If not isnumeric (testchar) then
Isvalidqqnumber = false
Exit Function
End if
Next
Next
End if

End Function

Function isvalidtelnumber (strtelephone)
'Determine the phone number format
Isvalidtelnumber = true
If Len (strtelephone) <= 0 then
Isvalidtelnumber = false
Exit Function
End if

If left (strtelephone, 1) = "-" Or right (strtelephone, 1) = "-" then
Isvalidtelnumber = false
Exit Function
End if

For I = 1 to Len (strtelephone)
Testchar = mid (strtelephone, I, 1)
If testchar <> "-" then
If not isnumeric (testchar) then
Isvalidtelnumber = false
Exit Function
End if
End if
Next

End Function

Function isvalidmobilenumber (strmobile)
'Determine the mobile phone number format
Isvalidmobilenumber = true
If Len (strmobile) <= 0 then
Isvalidmobilenumber = false
Exit Function
Else
If Len (strmobile)> 13 then
Isvalidmobilenumber = false
Exit Function
End if
End if

For I = 1 to Len (strmobile)
Testchar = mid (strmobile, I, 1)
If not isnumeric (testchar) then
Isvalidmobilenumber = false
Exit Function
End if
Next

End Function

Function isvalidemail (email)
'Determine the email format
Isvalidemail = true
Emailstr = Split (email ,"@")
If ubound (emailstr) <> 1 then
Isvalidemail = false
Exit Function
End if

For each emailchr in emailstr
If Len (emailchr) <= 0 then
Isvalidemail = false
Exit Function
End if
For I = 1 to Len (emailchr)
Testchar = lcase (mid (emailchr, I, 1 ))
If instr ("abcdefghijklmnopqrstuvwxyz _-.", testchar) <= 0 and not isnumeric (testchar) then
'If it is not a letter allowed by a character, it must be a number
Isvalidemail = false
Exit Function
End if
Next
'The Allowed characters must contain the decimal point
If left (emailchr, 1) = "." Or right (emailchr, 1) = "." Then
Isvalidemail = false
Exit Function
End if
Next

If instr (emailstr (1), ".") <= 0 then
Isvalidemail = false
Exit Function
End if
I = Len (emailstr (1)-limit Rev (emailstr (1 ),".")
If I <> 2 and I <> 3 then
Isvalidemail = false
Exit Function
End if
If instr (email, "...")> 0 then
Isvalidemail = false
End if
End Function

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.