$("#formAppointment").bootstrapValidator("addField", "employee", {
validators: {
notEmpty: {
message: '受访人员不能为空'
},
callback: {
message: '请选择受访人员',
callback: function (value, validator) {
if (value == -1) {
return false;
} else {
return true;
}
}
}, callback: {
message: '不可选择相同人员',
callback: function (value, validator) {
//return false;
let i = 0;
let flg = true;
let employee = $('.employee')[0].value;
let other = $('.employee');
console.log(other);
$.each(other, function (name, object) {
if (i != 0) {
if (employee == $(object).val()) {
console.log($(object).val());
flg = false;
return false;
}
}
i++;
});
if (flg) {
return true;
} else {
return false;
}
}
}
}
});