tagsInput的非可见字符验证提取到common.js中
This commit is contained in:
@@ -115,20 +115,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var hasInvisibleCharTags=[];
|
var flag1=validateInvisibleCharTag();
|
||||||
var reg = new RegExp(/\t|\r|\n/);
|
if(flag){
|
||||||
console.log($(".tagsinput").find(".tag").length);
|
flag=flag1;
|
||||||
$(".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){
|
if(flag){
|
||||||
//将disable属性的元素删除
|
//将disable属性的元素删除
|
||||||
@@ -136,7 +125,6 @@
|
|||||||
$(this).remove();
|
$(this).remove();
|
||||||
});
|
});
|
||||||
$("input[name$='exprType']").attr("disabled",false);
|
$("input[name$='exprType']").attr("disabled",false);
|
||||||
console.log(7777);
|
|
||||||
loading('onloading...');
|
loading('onloading...');
|
||||||
form.submit();
|
form.submit();
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -1102,3 +1102,21 @@ var importCfg=function(){
|
|||||||
$("#import_modal").modal('hide');//导入文件隐藏
|
$("#import_modal").modal('hide');//导入文件隐藏
|
||||||
$("#importForm1").submit();
|
$("#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