js 正则匹配
var s = password; var pattern = /^(?!\D+$)(?![^a-zA-Z]+$).{6,15}$/; if(pattern.test(s) == false) { errorMsg += '密码必须是字母和数字的组合' + '\n'; } if(errorMsg.length > 0) { mui.alert(errorMsg); }
密码
// 密码的正则匹配
$("#zhuce-password").blur(function(){
var password=/^[a-z0-9]{6,16}$/;
var zhucepassword=$("#zhuce-password").val();
if(!password.test(zhucepassword)){
$(".zhuce-error").css("display","block");
$(".zhuce-error").html();
$(".zhuce-error").html("<i></i><span>密码格式错误!请重新输入6-16位</span>");
return false;
}else{
$(".zhuce-error").css("display","none");
$(".zhuce-error").html();
}
});
手机号码
$("#zhuce-userName").blur(function(){ var mob=/^134[0-8]\d{7}$|^13[^4]\d{8}$|^14[5-9]\d{8}$|^15[^4]\d{8}$|^16[6]\d{8}$|^17[0-8]\d{8}$|^18[\d]{9}$|^19[8,9]\d{8}$/; var zhuceuserName=$("#zhuce-userName").val(); if(!mob.test(zhuceuserName)){ $(".zhuce-error").css("display","block"); $(".zhuce-error").html(); $(".zhuce-error").html("<i></i><span>手机号码格式错误!请重新输入</span>"); return false; } else{ $(".zhuce-error").css("display","none"); $(".zhuce-error").html(); } mobilepan(zhuceuserName); }) ;