销毁:
$("#saveModal #saveForm").data('bootstrapValidator').destroy();
$('#saveModal #saveForm').data('bootstrapValidator', null);
构建:
function validator(){
$('#saveModal #saveForm').bootstrapValidator({
message: 'This value is not valid',
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
device_type_code: {
validators: {
notEmpty: {
message: '设备类型编码不能为空'
}
}
},
device_type_name: {
validators: {
notEmpty: {
message: '设备类型不能为空'
}
}
},
vendor_code: {
validators: {
notEmpty: {
message: '厂商编码不能为空'
}
}
},
vendor_name: {
validators: {
notEmpty: {
message: '厂商名称不能为空'
}
}
},
product_code: {
validators: {
notEmpty: {
message: '产品编码不能为空'
}
}
},
product_name: {
validators: {
notEmpty: {
message: '产品名称不能为空'
}
}
},
product_model: {
validators: {
notEmpty: {
message: '产品型号不能为空'
}
}
},
device_port: {
validators: {
notEmpty: {
message: '端口号不能为空'
},
integer: {
message: '端口号必须为整数'
},
between: {
message: '端口号必须在0 ~ 65535之间',
min: 0,
max: 65535,
}
}
},
device_name: {
validators: {
notEmpty: {
message: '设备名称不能为空'
}
}
}
}
});
}
触发:
$("#saveModal #saveForm").data("bootstrapValidator").validate();
if(!$("#saveModal #saveForm").data("bootstrapValidator").isValid()){
return false;
}