常見的公用函數封裝方法(密碼強度、手機號驗證、郵箱驗證、輸入金額驗證)

來源:互聯網
上載者:User

標籤: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-][email protected]([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;
}
}

常見的公用函數封裝方法(密碼強度、手機號驗證、郵箱驗證、輸入金額驗證)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.