📄 db_isform.asp
字号:
<%
function Isform(values,types,forms)
dim valses
values=trim(values)
if trim(values)="" then
response.write "<script language=JavaScript>alert('["&forms&"] 不可以为空!');history.back();</script>"
response.End()
end if
select case types
case "数字"
if not isnumeric(values) then
response.write "<script language=JavaScript>alert('["&forms&"] 必须是数字!');history.back();</script>"
response.End()
end if
valses=int(valses)
case "汉字"
For i = 1 To Len(valses)
If Asc(Mid(valses, i, 1)) < 0 Then
response.write "<script language=JavaScript>alert('["&forms&"] 必须是汉字!');history.back();</script>"
response.End()
exit for
End If
Next
case "字符"
if not IsEnglish(valses) then
response.write "<script language=JavaScript>alert('["&forms&"] 必须是字符!');history.back();</script>"
response.End()
end if
case "中英"
For i = 1 To Len(valses)
If Asc(Mid(valses, i, 1)) < 0 or not IsEnglish(Mid(valses, i, 1))Then
response.write "<script language=JavaScript>alert('["&forms&"] 必须是汉字或者英文!');history.back();</script>"
response.End()
exit for
End If
Next
case "邮件"
if not IsValidEmail(values) then
response.write "<script language=JavaScript>alert('["&forms&"] 必须是正确的email地址!');history.back();</script>"
response.End()
end if
case "日期"
if not isdate(values) then
response.write "<script language=JavaScript>alert('["&forms&"] 必须是正确的日期格式 2002-11-19!');history.back();</script>"
response.End()
end if
case "身份证"
if not isnumeric(values) then
response.write "<script language=JavaScript>alert('["&forms&"] 必须是数字!');history.back();</script>"
response.End()
else
if len(values)<>15 and len(values)<>18 then
response.write "<script language=JavaScript>alert('["&forms&"] 必须是15或者18位数字!');history.back();</script>"
response.End()
end if
end if
case "邮编"
if not isnumeric(values) then
response.write "<script language=JavaScript>alert('["&forms&"] 必须是数字!');history.back();</script>"
response.End()
else
if len(values)<>6 then
response.write "<script language=JavaScript>alert('["&forms&"] 必须是6位数字!');history.back();</script>"
response.End()
end if
end if
end select
Isform=values
end function
function IsValidEmail(email)
dim names, name, i, c
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 IsEnglish(str)
on error resume next
dim n,i,l
n = Cstr(str)
IsEnglish = true
if isnull(str) then
IsEnglish = false
exit function
end if
l = len(n)
for i=1 to l
if (mid(n,i,1)<chr(65) or mid(n,i,1)>chr(90)) and (mid(n,i,1)<chr(97) or mid(n,i,1)>chr(122)) then
IsEnglish = false
exit function
exit for
end if
next
if err.number<>0 then err.clear
end function
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -