求ASP验证函数表单输入数据中只含有一个"—"

来源:百度知道 编辑:UC知道 时间:2024/05/16 15:32:23
要求在表单中输入数据,判断所输入的数据,使这些字符中至多有一个"—",此验证函数如何写?谢谢

if instr(mystring,"-")>0 then
pos=instr(mystring,"-")
tempstring=right(mystring,len(mystring)-pos+1)
if instr(tempstring,"-")>0 then
错误
else
正确
end if
else
正确
end if

dim str
str=request.from("TestText")
if instr(str,"-")>1 then
response.write("符合")
else
response.write("不符合")
end if

楼上的写的不对吧,应该是 <2 吧

dim str
str=request.from("TestText")
if instr(str,"—")<2 then
response.write("符合")
else
response.write("不符合")
end if