var reg = /\s*/g;
$('.modal-content').find('input').focusout(function () {
if ($(this).val() == '' || reg.test($(this).value)) {
$(this).css('backgroundColor','#FFEFEF');
$(this).nextAll('.hintWrap').css('display','block');
console.log(reg.test($(this).value));
} else {
$(this).css('backgroundColor','#F5F5F5');
$(this).nextAll('.hintWrap').css('display','none');
console.log(reg.test($(this).value));
}
})
谢谢!
/s*/g能匹配成功任意字符,(包括空串。个数随意,没有也行).因为所有的都能包含""。
评论区转码了,写这了