标签:ida 账号 方法 his phone .config test 验证 val
//密码复杂度公共函数封装(邮箱,手机号)
this.PasswordStrength = function(password) {
var rule = Auto517.config.passwordRule.rule;
var min = Auto517.config.passwordRule.min;
var max = Auto517.config.passwordRule.max;
if(rule == 0 && eval(‘/^[0-9]{‘ + min + ‘,‘ + max + ‘}$/.test(password)‘)) {
return true;
} else if(rule == 1 && eval(‘/^[a-zA-Z]{‘ + min + ‘,‘ + max + ‘}$/.test(password)‘)) {
return true;
} else if(rule == 2 && eval(‘/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{‘ + min + ‘,‘ + max + ‘}$/.test(password)‘)) {
return true;
} else {
return false;
}
}
//手机号验证
this.PhoneNumberValidation = function(phonenum) {
if(/^1[3,4,5,7,8]\d{9}$/.test(phonenum)) {
return true;
} else {
return false;
}
}
//邮箱账号验证
this.MailboxValidate = function(email) {
if(/^[_\.0-9a-zA-Z-]+@([0-9a-z][0-9a-z-]+\.){1,4}[a-z]{2,3}$/.test(email)) {
return true;
} else {
return false;
}
}
//输入金额验证
this.EnterTheAmount = function(money) {
var rule = Auto517.config.moneyRule.rule;
var min = Auto517.config.moneyRule.min;
if(rule == 0 && /^[0-9]+(.[0-9]{1,2})?$/.test(money)) {
if(money >= min) {
return true;
} else {
return false;
}
} else if(rule == 1 && /^\+?[1-9][0-9]*$/.test(money)) {
if(money >= min) {
return true;
} else {
return false;
}
} else {
return false;
}
}
常见的公共函数封装方法(密码强度、手机号验证、邮箱验证、输入金额验证)
标签:ida 账号 方法 his phone .config test 验证 val
原文地址:http://www.cnblogs.com/huguangxu/p/6243971.html