我现在有个冲突就是第2个验证和第3个验证有冲突,他会去执行第2个,不执行第3个
其实好像是第2个已经包括了第3个验证,
我该怎么去验证密码不能少于6位数且只能是数字和字母,但又要能判断客户输入的是什么东西??
$("input[name=password]").change(function() {
//1.验证是否为空
if ($(this).val() == "") {
$("input[name=password]").focus();
return false;
}
//2.验证是否大于0小于6
if ($(this).val().replace(/\s+/g, "").length > 0 && $(this).val().replace(/\s+/g, "").length < 6) {
$(".ptext2").show().html("密码不能小于6位数");
return flase;
}
//3.验证输入的是否是数字和字母
if(!reg.test(this.value)){
$(".ptext2").show().html("只能输入数字和字母");
return flase;
}
});