ASP验证邮箱是否正确的代码谁帮忙看一下

来源:百度知道 编辑:UC知道 时间:2024/06/01 07:45:19
Response.ContentType="text/html"
Response.Charset="gb2312"
aa=request.QueryString("UserEmail")
if IsValidEmail(aa) then
response.Write "格式正确"
else
response.write "格式错误."
end if
function IsValidEmail(email)
dim names, name, i, c
IsValidEmail = true
names = Split(email, "@")
if UBound(names) <> 1 then
IsValidEmail = false
exit function
end if
if len(email) > 100 then
IsValidEmail = false
exit function
end if
for each name in names
if Len(name) <= 0 then
IsValidEmail = false
exit function
end if
for i = 1 to Len(name)
c = Lcase(Mid(name, i, 1))
if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
IsValidEmail = false
exit function
end if
next
if Left(name, 1) = "." or Right(name, 1) = "

asp我不会哦.
用javascript嘛

<script language="javascript">
function myCheck(){
var supported = 0;
if (window.RegExp) {
var tempStr = "a";
var tempReg = new RegExp(tempStr);
if (tempReg.test(tempStr)) supported = 1;
}
if (!supported)
return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
if (!r1.test(document.all.EM.value) && r2.test(document.all.EM.value))
{
return true ;
}else{
alert("你输入的邮箱地址有误