龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > asp编程 >

二款asp 邮箱地址验证代码

时间:2012-12-31 22:56来源:未知 作者:admin 点击:
分享到:
二款asp教程 邮箱地址验证代码 邮箱验证代码一 html head titleexample30/title % function chkemail(email)'定义过程 chkemail=true'初始化函数结果 names=split(email,@)'split函数是将字符串用指定的字符分割成

二款asp教程 邮箱地址验证代码
邮箱验证代码一
<html>
<head>
<title>example30</title>
<%
 function chkemail(email)       '定义过程
  chkemail=true        '初始化函数结果          
  names=split(email,"@")       'split函数是将字符串用指定的字符分割成多个子字符串,并将这些子字符串保存在一维数组中
  if ubound(names)<>1 then      'ubound函数返回数组的最大下标
   chkemail=false       '邮件格式错误,返回false
   exit function       '跳出过程
  end if
  for each name in names       'for each循环语句
   if len(name)<=0 then      'len函数获得字符串的长度
    chkemail=false      '邮件格式错误,返回false
    exit function      '跳出过程
   end if
  next
 end function                '结束过程的定义
%>
</head>
<body>
<form method="post" action="example30.asp" name = form1>
 <p align="center">请输入电子邮箱:<input type="text" name="email" size="20" value=<%=request.form("email")%>></p>
 <p align="center"><input type="submit" value="确定" name="submit"></p>
</form>
<%
 if request.form("submit")="确定" then      '单击【确定】按钮
  email=request.form("email")      '读取输入的字符串
  if chkemail(email) then       '调用chkemail过程
   response.write("<script>alert('邮件格式正确')</scirpt>") '返回true,则提示格式正确
  else         '返回false
   response.write("<script>alert('邮件格式错误')</script>") '提示格式错误
  end if
 end if
%>
</body>
</html>

邮箱验证代码二
<html>
<head>
<title>example31</title>
</head>
<body>
<form method="post" action="example31_index.asp" name = form1>
 <p align="center">请输入电子邮箱:<input type="text" name="email" size="20" value=<%=request.form("email")%>></p>
 <p align="center"><input type="submit" value="确定" name="submit"></p>
</form>
<%
 if request.form("submit")="确定" then      '单击【确定】按钮
  email=request.form("email")      '读取输入的字符串
  if chkemail(email) then       '调用chkemail过程
   response.write("<script>alert('邮件格式正确')</scirpt>") '返回true,则提示格式正确
  else         '返回false
   response.write("<script>alert('邮件格式错误')</script>") '提示格式错误
  end if
 end if
%>
</body>
</html>


精彩图集

赞助商链接