http tags输入的标签做不可见字符的验证

This commit is contained in:
wangxin
2018-08-17 15:10:30 +08:00
parent 18678f14b5
commit 05fca7be1b
4 changed files with 35 additions and 8 deletions

View File

@@ -115,12 +115,28 @@
}
}
});
var hasInvisibleCharTags=[];
var reg = new RegExp(/\t|\r|\n/);
console.log($(".tagsinput").find(".tag").length);
$(".tagsinput").find(".tag").each(function(){
var text=$(this).children("span").text();
if (text.match(reg)) {
hasInvisibleCharTags.push("'"+text+"'");
flag = false;
}
});
if(hasInvisibleCharTags.length==1){
$(".tagsinput").parents(".col-md-6").next("div").html("<label class='error'>"+$.validator.messages.hasInvisibleChar.replace("{0}",hasInvisibleCharTags.join(","))+"</label>");
}else if(hasInvisibleCharTags.length>=1){
$(".tagsinput").parents(".col-md-6").next("div").html("<label class='error'>"+$.validator.messages.haveInvisibleChar.replace("{0}",hasInvisibleCharTags.join(","))+"</label>");
}
if(flag){
//将disable属性的元素删除
$(".disabled").each(function(){
$(this).remove();
});
$("input[name$='exprType']").attr("disabled",false);
console.log(7777);
loading('onloading...');
form.submit();
}else{