核心提示:有时会员提交邮箱时乱填写邮箱或者是不小心填写错了邮箱,下面咱们写个代码判断一下邮箱正确的问题1.function CheckEmail(str){ var sReg = /[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+$/; if ( ! sRe...
有时会员提交邮箱时乱填写邮箱或者是不小心填写错了邮箱,下面咱们写个代码判断一下邮箱正确的问题
1.
function CheckEmail(str){
var sReg = /[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+$/;
if ( ! sReg.test(str) )
{
alert("Email地址错误!请重新输入。");
return false;
}
return true;
}
2.
<script language="VBScript"><!--
function chkEmail(email)
on error resume next
dim i,l,pos1,pos2
chkEmail=true
if isnull(email) then chkEmail=false:exit function
pos1= instr(email,"@")
pos2=instrRev(email,".")
if not(pos1>0) or not (pos2>0) or pos1>pos2 then
chkEmail=false
end if
if err.number<>0 then err.clear
end function
--></script>