function verifyCompany(company){
//不能连续字符(如123、abc)连续3位或3位以上
if(!LxStr(company)){
$.ecCommon.ecAlert({
msg: '不允许录入3个连续或者重复数字、字母',
});
return false;
}
//不能相同字符(如111、aaa)连续3位或3位以上
var re = /(\w)*(\w)\2{2}(\w)*/g;
if(re.test(company)){
$.ecCommon.ecAlert({
msg: '不允许录入3个以上重复数字、字母',
});
return false;
}
}
function verifyEmail(email){
//不能连续字符(如123、abc)连续3位或3位以上
if(!LxStr(email)){
$.ecCommon.ecAlert({
msg: '不允许录入3个连续或者重复数字、字母',
});
return false;
}
//不能相同字符(如111、aaa)连续3位或3位以上
var re = /(\w)*(\w)\2{2}(\w)*/g;
if(re.test(email)){
$.ecCommon.ecAlert({
msg: '不允许录入3个以上重复数字、字母',
});
return false;
}
if(email.indexOf('@')<=3){
$.ecCommon.ecAlert({
msg: '邮箱@符号前必须超过3个字符',
});
return false;
}
}
//不能连续字符(如123、abc)连续3位或3位以上
LxStr = function(str){
var arr = str.split('');
var flag = true;
for (var i = 1; i < arr.length-1; i++) {
var firstIndex = arr[i-1].charCodeAt();
var secondIndex = arr[i].charCodeAt();
var thirdIndex = arr[i+1].charCodeAt();
thirdIndex - secondIndex == 1;
secondIndex - firstIndex==1;
if((thirdIndex - secondIndex == 1)&&(secondIndex - firstIndex==1)){
flag = false;
}
}
if(!flag){
$.ecCommon.ecAlert({
msg: '不允许录入3个连续或者重复数字、字母',
});
return false;
}
return flag;
}
网友评论