电子邮箱验证函数

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.111cn.net/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>电子邮箱验证函数</title>

<script language="javascript教程">
if (document.form.email.value==""){   
    alert("email地址不能为空!");   
    form.email.focus();   
    return false;   
}   
if(!/w+@w+(.w+)+/ig.test(document.form.email.value)){   
  alert('请正确填写email格式!^_^');   
  form.email.focus();   
    return false;   
}
</script>

</head>

<body>
</body>
</html>

方法二

 

function isemail(str)

{

var reg=/^w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*$/; 或者是

var myreg = /^[-_a-za-z0-9.]+@([_a-za-z0-9]+.)+[a-za-z0-9]{2,3}$/;

return reg.test(str);

}

时间: 2024-09-20 06:02:14

电子邮箱验证函数的相关文章

四种asp 电子邮箱验证函数

Public Function IsEmail(ByVal PString) Dim Plt,Pgt : Plt = False : Pgt = False For x = 2 To Len(PString) - 1 If Mid(PString,x,1) = "@" Then Plt = True If Mid(PString,x,1) = "." And Plt = True Then Pgt = True Next If Plt = True And Pgt

JavaScript验证电子邮箱的函数_javascript技巧

本文介绍一个JavaScript验证电子邮箱的函数,相当靠谱. JavaScript验证电子邮箱的函数,源代码如下: function checkEmail(text) { if( text.match(/qq\.com$/) ) { return -1; } if( ! text.match(/^\w+([._-]\w+)*@(\w+\.)+\w+$/) ) { return false; } return true; } 关于JavaScript验证电子邮箱的函数,本文就介绍这么多,希望对您

asp 电子邮箱email验证实例程序

 电子邮箱email验证实例程序 function IsValidEmail(email) dim names, name, i, c 'Check for valid syntax in an email address. IsValidEmail = true names = Split(email, "@") if UBound(names) <> 1 then    IsValidEmail = false    exit function end if for e

asp邮箱email地址正则表达式验证函数

函数名:chk_Email() '返回值:布尔值(True为通过,False为未通过) '参数:email(需要判断的email,类型:字符串)   Type_1(是否需要判断@之后的domain,类型:布尔值) 'Type_2(是否只能是特定域的E-Mail注册,类型:布尔值) Type_3(一个E-Mail是否只能注册一次,类型:布尔值) Const C_maildomain=".com,.com.cn,.net,.net.cn,.org,.org.cn,.gov,.gov.cn,.edu,

js与jquery正则验证电子邮箱、手机号、邮政编码的方法_javascript技巧

本文实例讲述了js与jquery正则验证电子邮箱.手机号.邮政编码的方法. jQuery代码: //验证邮政编码 $("#postcode").blur(function(){ //获取邮政编码 var postcode=$("#postcode").val(); if(is_postcode(postcode)){ $("#postcode_info").html(""); }else{ $("#postcode_

最全面的js验证电子邮箱的正则表达式

先看如下一段代码:  代码如下 复制代码 function isValidMail(sText){ var reMail = /^(?:w+.?)*w+@(?:w+.?)*w+$/; return reMail.test(sText); } 似乎这样验证像sofish@163.com这样的邮箱是没问题的.但,由于仔细看一下在AT(@)后面的非捕获性引用中,使用 的是*(出现任意次):  代码如下 复制代码 var reMail = /^(?:w+.?)*w+@(?:w+.?)*w+$/; 那么,

javascript 通用验证函数库(电话,邮箱,手机,数字)

网页特效 通用验证函数库(电话,邮箱,手机,数字) 这个验证库是我们常用的 电话,邮箱,手机,数字 QQ, 字母,中文,英文等验证函数. /* @author:slchen @exemple:  var email="slchen@xxxxx.com";  alert($v.IsEmail(email)); */ var $v=(function(){ Function.prototype.method = function(name, fn) { this.prototype[nam

常用邮箱地址 ip地址 英文用户名验证函数

常用邮箱地址 ip地址 英文用户名验证函数 */ // function to check e-mail address like string  function isemail (s)  {   // there must be >= 1 character before @, so we   // start looking at character position 1   // (i.e. second character)   var i = 1;   var slength = s

服务器与客户端的邮箱地址验证函数

  邮箱地址验证有很多方法.在浏览器端,js邮箱验证可以通过正则表达式检测.  代码如下   function isEmail(email) {     return /^((([a-z]|d|[!#$%&'*+-/=?^_`{|}~]|[u00A0-uD7FFuF900-uFDCFuFDF0-uFFEF])+(.([a-z]|d|[!#$%&'*+-/=?^_`{|}~]|[u00A0-uD7FFuF900-uFDCFuFDF0-uFFEF])+)*)|((x22)((((x20|x09