首页 > 代码库 > 邮箱正则校验
邮箱正则校验
var should = require(‘should‘);describe(‘Array‘, function() { describe(‘#indexOf()‘, function() { it(‘should return -1 when the value is not present‘, function() { true.should.be.eql(verifyMultipleEmail("aa@qq.com")); false.should.be.eql(verifyMultipleEmail("aa,@qq.com")); true.should.be.eql(verifyMultipleEmail("aa@qq.com, cc@163.com")); false.should.be.eql(verifyMultipleEmail("aa@qq.com, ,cc@163.com")); false.should.be.eql(verifyMultipleEmail("aa@qq.com, cc@163.com,")); false.should.be.eql(verifyMultipleEmail(",")); false.should.be.eql(verifyMultipleEmail("@")); true.should.be.eql(verifyMultipleEmail("lkj_jl@k.com")); }); });});function verifyMultipleEmail(email) { var _result = false; var _temp = ‘‘; if(email.indexOf(‘\,‘) === (-1)) { _result = verifyEmail(email); return _result; } var _array = email.split("\,"); _result = true; _array.forEach(function(value, index, full) { _temp = value.replace(‘ ‘, ‘‘); if(!verifyEmail(_temp)) { _result = false; } }) return _result;}function verifyEmail(email) { var reg = /^[a-z_0-9.-]{1,64}@([a-z0-9-]{1,200}.){1,5}[a-z]{1,6}$/; return email.match(reg) ? true : false;}
邮箱正则校验
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。