commit.onclick=function (){
var AZpass = /[A-Z]/.test(demo.value);
var azpass = /[a-z]/.test(demo.value);
var dpass = /\d/.test(demo.value);
var wordpass = /[^\w]/.test(demo.value);
var spacepass = /\s/.test(demo.value);
var lengthpass = /^\w{6,10}$/.test(demo.value); //字符在6至10之间
var pass = AZpass && azpass && dpass && (!wordpass) && (!spacepass) && lengthpass;
console.log(lengthpass);
if(!pass){
console.log("The infomation you entered is not compliant");
}else{
console.log("The infomation you entered is validated successfully");
};
};
或者用相反的思路:
能,但是如果写在一句,你就没法针对性给出错误提示了。
正则表达式被滥用,可真不是好事
分步截取,并与运算符搭配使用
拿来主义。。。。
不限制长度么。。。
限制符号么?