//账号格式5-12位数字
var accountPattern = /^\d{5,12}$/;
//密码格式6-22位字母数字
var passwordPattern = /^[a-zA-Z0-9]{6,22}$/;
//验证码格式4位字母数字
var codePattern = /^[a-zA-Z0-9]{4}$/;
//检测账号格式
function testAccount(account){
if(accountPattern.test(account)){
return true;
}else{
return false;
}
}
//检查密码
function testPassword(password){
if(passwordPattern.test(password)){
return true;
}else{
return false;
}
}
//检查验证码
function testCode(code){
if(codePattern.test(code)){
return true;
}else{
return false;
}
}
js账户密码简单验证
最新推荐文章于 2024-04-25 23:56:41 发布