asp:求大师帮忙,我的这个判断特殊字符,为什么不起作用

来源:百度知道 编辑:UC知道 时间:2024/05/11 12:48:36
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script language=VBScript>
Sub Check()
If Request.Form("submit") = "提交" Then
If InStr(Request.Form("str"),"@")<=0 Then
alert('输入的字符串中不包含@字符')
Else
alert('输入的字符串中包含@字符')
End If
End If
end sub
</script><

Sub Check()
If Request.Form("submit") = "提交" Then
If InStr(Request.Form("str"),"@")>0 Then
alert('输入的字符串中包含@字符')
Else
alert('输入的字符串中不包含@字符')
End If
End If
end sub

你写的那个不对,用js来做。
var strm = document.myform.CoMail.value //提交mail地址的文本框
var regm = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;//验证Mail的正则表达式,^[a-zA-Z0-9_-]:开头必须为字母,下划线,数字,
if (!strm.match(regm) && strm!="")
{
alert("邮箱地址格式错误或含有非法字符!\n请检查!");
document.myform.CoMail.select();
return false;
}

alert('输入的字符串中不包含@字符') 单引改为双引号