tagsInput的非可见字符验证提取到common.js中
This commit is contained in:
@@ -115,20 +115,9 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
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>");
|
||||
var flag1=validateInvisibleCharTag();
|
||||
if(flag){
|
||||
flag=flag1;
|
||||
}
|
||||
if(flag){
|
||||
//将disable属性的元素删除
|
||||
@@ -136,7 +125,6 @@
|
||||
$(this).remove();
|
||||
});
|
||||
$("input[name$='exprType']").attr("disabled",false);
|
||||
console.log(7777);
|
||||
loading('onloading...');
|
||||
form.submit();
|
||||
}else{
|
||||
|
||||
@@ -1101,4 +1101,22 @@ var importCfg=function(){
|
||||
}
|
||||
$("#import_modal").modal('hide');//导入文件隐藏
|
||||
$("#importForm1").submit();
|
||||
}
|
||||
}
|
||||
var validateInvisibleCharTag=function(){
|
||||
var hasInvisibleCharTags=[];
|
||||
var reg = new RegExp(/\t|\r|\n/);
|
||||
$(".tagsinput").find(".tag").each(function(){
|
||||
var text=$(this).children("span").text();
|
||||
if (text.match(reg)) {
|
||||
hasInvisibleCharTags.push("'"+text.trim()+"'");
|
||||
}
|
||||
});
|
||||
if(hasInvisibleCharTags.length==1){
|
||||
$(".tagsinput").parents(".col-md-6").next("div").html("<label class='error'>"+$.validator.messages.hasInvisibleChar.replace("{0}",hasInvisibleCharTags.join(","))+"</label>");
|
||||
return false;
|
||||
}else if(hasInvisibleCharTags.length>=1){
|
||||
$(".tagsinput").parents(".col-md-6").next("div").html("<label class='error'>"+$.validator.messages.haveInvisibleChar.replace("{0}",hasInvisibleCharTags.join(","))+"</label>");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user