手機號碼、密碼的正則驗證規則


1.驗證手機號碼是否符合規則,包括主流的號段
var mobile={
validate_mobile:function (mobile){
var mobilePattern={mobile: /^(((13[0-9])|(14[5-7])|(15[0-9])|(17[0-9])|(18[0-9]))+\d{8})$/ };
if(!mobilePattern.mobile.test(mobile)){
return false;
}
return true;
}
}
2.驗證密碼時候符合規則--包含數字和英文字母

validate_password:function(password){
var passwordPattern=/^(?![0-9]+$)(?![a-zA-Z]+$)[a-zA-Z\d]{6,16}$/;
if(!passwordPattern.test(password)){
return false;
}
return true;
},


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM