bootstrap validate 验证插件 动态添加和动态删除验证项
//添加验证项
function addField(field, notEmptyMsg, othercon) { if (!othercon) { $("#gyssave").bootstrapValidator("addField", field, { validators: { notEmpty: { message: "" } } }); } else { $("#gyssave").bootstrapValidator("addField", field, othercon); } /* $("#formdata").bootstrapValidator("message","");*/ /* $('#formdata').bootstrapValidator({message:''});*/ // $(formName).data("bootstrapValidator").resetForm(); $('#gyssave') .data('bootstrapValidator') .updateStatus(field, 'NOT_VALIDATED', null) .validateField(field); } //添加验证项,出发方式为“change” function addFieldtrigger(field, notEmptyMsg, othercon) { if (!othercon) { $("#gyssave").bootstrapValidator("addField", field, { trigger: 'change', validators: { notEmpty: { message: "" } } }); } else { $("#gyssave").bootstrapValidator("addField", field, othercon); } $("input[name=" + field + "]").trigger('change') $('#gyssave') .data('bootstrapValidator') .updateStatus(field, 'NOT_VALIDATED', null) .validateField(field); } //移除验证项 function removeField(field) { $("#gyssave").bootstrapValidator("addField", field, {}); /* $('#formdata') .data('bootstrapValidator') .updateStatus(field, 'NOT_VALIDATED', null) .validateField(field);*/ $("#gyssave").bootstrapValidator("removeField", field) }