<% function htmlencode2(str)
dim result
dim l
if isNULL(str) then
htmlencode2=""
exit function
end if
l=len(str)
result=""
dim i
for i = 1 to l '对返回的内容进行判定,并对其含有<,>,chr(13),chr(34),&,chr(32),chr(9)进行相应的转化,如chr(13)变为<BR> 也就是回车的HTM代码
select case mid(str,i,1)
case "<" result=result+"<"
case ">" result=result+">"
case chr(13) result=result+"<br>"
case chr(34) result=result+"""
case "&" result=result+"&"
case chr(32) result=result'+" "
if i+1<=l and i-1>0 then
if mid(str,i+1,1)=chr(32) or mid(str,i+1,1)=chr(9) or mid(str,i-1,1)=chr(32) or mid(str,i-1,1)=chr(9) then
result=result+" "
else result=result+" "
end if
else result=result+" "
end if
case chr(9) result=result+" "
case else result=result+mid(str,i,1)
end select
next
htmlencode2=result
end function
%>
1、
function testchar(t0,t1)
checkOK = t0
checkStr = t1
allValid = True
For i = 1 to len(checkStr)
ch = Mid(checkStr, i, 1)
If (InStr(checkOK, ch) = 0) Then
allValid = False
Exit For
End If
Next
If (Not allValid) Then
testchar=true
else
testchar=false
End If
end function
function lfy_onsubmit()
Set theForm = document.lfy
if testchar("abcdefghijklmnopqrstuvwxyz",theForm.cz.value) then
MsgBox "在 cz 域中,只能输入小写字母。", 0, "有效性验证错误"
theForm.cz.focus()
lfy_onsubmit = False
Exit Function
End If
lfy_onsubmit = True
End Function
lfy为form名
2、
function replzf(mrepl)
mrepl=replace(mrepl,"'","''")
mrepl=replace(mrepl,chr(13),"<br>")
mrepl=replace(mrepl," "," ")
mrepl=replace(mrepl,"<","<")
mrepl=replace(mrepl,">",">")
replzf=mrepl
end function