日期:2014-01-07  浏览次数:20788 次

最近常有朋友问我如何在ASP中象在JavaScrip里一样控制输入的值只能是英文或数字,现在我整理如下,下面我以接收变量string的值讲解如下:



方法一:
str=Request("string")
temp=Server.URLEncode(str)
if str=temp then
  response.write "你输入的不是英文或数字"
end if



文法二:
str=Request("string")
for i=1 to len(str)
   a=mid(string,i,1)
   if ((asc(a)<"0" and asc(a)>"9" ) or (asc(a)<asc("a") and asc(a)>asc("z"))) then
  response.write "你输入的不是英文或数字"
 end if
next i