var kongge=/\s/g;
var addphone=$('#changeEmpPhone').attr("value");//input的输入框要求输入空格提示错误
if (addname=="") {
$('#noname2').html("不能为空");
} else {
$('#noname2').html("");
console.log(addname);
console.log(kongge);
console.log(typeof kongge.test(addname));
if(kongge.test(addname)){
alert(1122);
$('#noname2').html("不能包含空格");
}else{
$('#noname2').html("");
count1 =count1+1;
console.log(22);
}
}
发现第一次输入空格,提交后,正则返回true
内容不变再次提交,正则返回false?而且还alert(1122)了。。。
第三次内容还不变,提交,正则返回true?
三次一循环
我已经崩溃了,求大神解释