js 验证电子邮箱
2013-07-15 23:36
281 查看
js:
<script type="text/JavaScript">
function checkemail()
{
var temp = document.getElementById("email");
var myreg = /(\S)+[@]{1}(\S)+[.]{1}(\w)+/;
if(temp.value!="")
{
if(!myreg.test(temp.value))
{
document.getElementById("mail").innerHTML="请输入有效的emailemail!";
document.getElementById("mail").style.color="red";
temp.value="";
temp.focus();
return false;
}
else{
document.getElementById("mail").innerHTML="emailemail可以使用";
document.getElementById("mail").style.color="green";
}
}
}
</script>
html body部分
邮箱地址:<input id="email" name="email" onBlur="checkemail()" type="text" /><span id="mail"></span> <br>
<script type="text/JavaScript">
function checkemail()
{
var temp = document.getElementById("email");
var myreg = /(\S)+[@]{1}(\S)+[.]{1}(\w)+/;
if(temp.value!="")
{
if(!myreg.test(temp.value))
{
document.getElementById("mail").innerHTML="请输入有效的emailemail!";
document.getElementById("mail").style.color="red";
temp.value="";
temp.focus();
return false;
}
else{
document.getElementById("mail").innerHTML="emailemail可以使用";
document.getElementById("mail").style.color="green";
}
}
}
</script>
html body部分
邮箱地址:<input id="email" name="email" onBlur="checkemail()" type="text" /><span id="mail"></span> <br>
相关文章推荐
- 【js与jquery】电子邮箱、手机号、邮政编码的正则验证
- js验证 正则表达式 包含手机号码、座机号码、电子邮箱、密码、姓名、身份证号码等表单数据的验证
- JAVA、JS中验证身份证号码、手机号码、电子邮箱的正则表达式
- js验证电子邮箱
- 【js与jquery】电子邮箱、手机号、邮政编码的正则验证
- js验证电子邮箱格式是否正确的代码
- js 验证电子邮箱
- js验证是否为空、数字、邮政编码、联系电话、传真、电子邮箱格式(公用js)
- js验证电子邮箱格式是否正确的代码
- js验证电子邮箱的正则表达式
- js与jquery正则验证电子邮箱、手机号、邮政编码的方法
- 在JS中使用正则表达式验证电子邮箱是否正确
- js验证电子邮箱,js验证email合法性,javascript验证电子信箱
- 常用正则表达式大全,手机、电话、邮箱、身份证(最严格的验证)、IP地址、网址、日期等,一般前台js验证,来这里就够了...
- JS验证(电话、邮箱。。。)
- JS邮箱验证-正则验证
- JS正则表达式验证账号、手机号、电话和邮箱
- JS邮箱验证-正则验证
- JS验证手机和邮箱
- js验证邮箱、手机