常用的一些判断

判断输入域名是否正确的函数:
dim c,words,word,i,wnum
function IsValiddomin(word)
IsValiddomin = true
words = Split(word, ".")
wnum=UBound(words)
if words(0)="www" then
IsValiddomin = IsValidword(words(1))
IsValiddomin = IsValidword2(words(2))
if words(wnum)="cn" then
if wnum<>3 then
IsValiddomin = false
exit function
end if
else
if wnum<>2 then
IsValiddomin = false
exit function
end if
end if
else
IsValiddomin = IsValidword(words(0))
IsValiddomin = IsValidword2(words(1))
if words(wnum)="cn" then
if wnum<>2 then
IsValiddomin = false
exit function
end if
else
if wnum<>1 then
IsValiddomin = false
exit function
end if
end if
end if
end function

function IsValidword2(word)
IsValidword2 = true
IsValidword2 = IsValidword(word)
if word<>"net" and word<>"com" and word<>"cc" and word<>"org" and word<>"info" and word<>"gov" then ' 自己添加
IsValidword2 = false
exit function
end if
end function

function IsValidword(word)
IsValidword = true

if Len(word) <= 0 then
IsValidword = false
exit function
end if
for i = 1 to Len(word)
c = Lcase(Mid(word, i, 1))
if InStr("abcdefghijklmnopqrstuvwxyz-", c) <= 0 and not IsNumeric(c) then
IsValidword = false
exit function
end if
next
end function

if IsValiddomin("wrclub.net.cn") then
response.write "right"
else
response.write "wrong"
end if


判断是否含有中文字符函数,函数主要用于设置密码,如ftp密码设置:

function nothaveChinese(para)
dim str
nothaveChinese=true
str=cstr(para)
for i = 1 to Len(para)
c=asc(mid(str,i,1))
if c<0 then
nothaveChinese=false
exit function
end if
next
end function


限制字符是否中文代码:
function isChinese(para)
on error resume next
dim str
dim i
if isNUll(para) then
isChinese=false
exit function
end if
str=cstr(para)
if trim(str)="" then
isChinese=false
exit function
end if
for i=1 to len(str)
c=asc(mid(str,i,1))
if c>=0 then
isChinese=false
exit function
end if
next
isChinese=true
if err.number<>0 then err.clear
end function


判断Email是否正确函数:
function IsValidEmail(email)
dim names, name, i, c
'Check for valid syntax in an email address.
IsValidEmail = true
names = Split(email, "@")
if UBound(names) <> 1 then
IsValidEmail = false
exit function
end if
for each name in names
if Len(name) <= 0 then
IsValidEmail = false
exit function
end if
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
end if
next
if Left(name, 1) = "." or Right(name, 1) = "." then
IsValidEmail = false
exit function
end if
next
if InStr(names(1), ".") <= 0 then
IsValidEmail = false
exit function
end if
i = Len(names(1)) - InStrRev(names(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


判断电话号码是否正确函数:
function IsValidTel(para)
on error resume next
dim str
dim l,i
if isNUll(para) then
IsValidTel=false
exit function
end if
str=cstr(para)
if len(trim(str))<7 then
IsValidTel=false
exit function
end if
l=len(str)
for i=1 to l
if not (mid(str,i,1)>="0" and mid(str,i,1)<="9" or mid(str,i,1)="-") then
IsValidTel=false
exit function
end if
next
IsValidTel=true
if err.number<>0 then err.clear
end function
 



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值