$("input:checkbox").on("ifChecked", function(event){
var cId = $(this).attr("name");
addField("seqNum"+cId,"顺序必填");
addField("discount"+cId,"折扣率必填");
});
$("input:checkbox").on("ifUnchecked", function(event){
console.log($(this).attr("name"))
var cId = $(this).attr("name");
removeField("seqNum"+cId);
removeField("discount"+cId);
});
function addField(field,notEmptyMsg){
$(".editForm").bootstrapValidator("addField", field,{
validators: {
notEmpty: {
message: notEmptyMsg
}
}
});
}
function removeField(field){
$(".editForm").bootstrapValidator("addField", field,{});
$(".editForm").bootstrapValidator("removeField", field)
}
bootstrapValidator动态添加校验字段
猜你喜欢
转载自fudk-k.iteye.com/blog/2335168
今日推荐
周排行