asp验证中文代码

来源:百度知道 编辑:UC知道 时间:2024/05/18 20:42:11
dim strLy
strLy=trim(request.Form("liuyanneirong"))
<%
Function FullChinese(str)
Dim i
If i=0 Then
FullChinese=False

Exit Function
End If
Do While i>0
If Asc(Mid(str,i,1))<10000 And Asc(Mid(str,i,1))>-10000 Then
FullChinese=False
Exit Function
End If
i=i-1
Loop
FullChinese=True
End Function
%>
<%
if(FullChinese(strLy)=true) then
rst("kcontent")=strLy
response.Write "<script > alert('输入格式正确');history.back();</script>"

else
response.Write"<script > alert('请返回输入正确的中文,谢谢合作!');history.back();</script>"
end if
这个逻辑哪里出错了,我不想用js,想在服务器端拦截,可是老是提示'请返回输入正确的中文,谢谢合作!',高手帮忙啊
if(FullChinese(strLy)=true) then
rst(

你只定义了变量 I 但是I 没有任何值
根据你的意思,I的值应该是字符串的长度
所以 将FullChinese这个函数修改为:
Function FullChinese(str)
Dim i
i=len(str) '加上这一句
If i=0 Then
FullChinese=False

Exit Function
End If
Do While i>0
If Asc(Mid(str,i,1))<10000 And Asc(Mid(str,i,1))>-10000 Then
FullChinese=False
Exit Function
End If
i=i-1
Loop
FullChinese=True
End Function