完美验证正则
作者:chrispy
邮箱验证function isEmail(str){var reg = /([a-z0-9A-Z]+[-|.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?.)+[a-zA-Z]{2,}$/;return reg.test(str);}var str = '15336534@qq.com';document.write(isEmail(str)+'<br />');var str2 =
邮箱验证
function isEmail(str){
var reg = /([a-z0-9A-Z]+[-|.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?.)+[a-zA-Z]{2,}$/;
return reg.test(str);
}
var str = '15336534@qq.com';
document.write(isEmail(str)+'<br />');
var str2 = 'test@sima.vip.com';
document.write(isEmail(str2)+'<br />');
var str3 = 'te-st@qq.com.cn';
document.write(isEmail(str3)+'<br />');
var str4 = 'te_st@sima.vip.com';
document.write(isEmail(str4)+'<br />');
var str5 = 'te.._st@sima.vip.com';
document.write(isEmail(str5)+'<br />');
手机号验证
var obj = {};
obj.phone = 18910144883;
var reg = /^(1[2|3|4|5|6|7|8|9][0-9]{9})?$/;
if(!reg.test(obj.phone)){
console.log('手机号码输入有误');
return false;
}