作者:mobiledu2502875123 | 来源:互联网 | 2023-07-07 23:19
var Validate = $('#save_form').bootstrapValidator({
message: 'This value is not valid',
// excluded: [':disabled'], //[':disabled', ':hidden', ':not(:visible)']
excluded: [":disabled"], //关键配置,表示只对于禁用域不进行验证,其他的表单元素都要验证
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
name: {
container: '#',
message: '验证失败',
trigger: "change",
validators: {
notEmpty: { message: '请输入产品名' },
regexp: { regexp: /^[a-zA-Z0-9_]+$/, message: '用户名只能包含大写、小写、数字和下划线' },
emailAddress: { message: '邮箱地址格式有误' },
phone: { message: '请输入正确的手机号码', country: 'CN' },
choice: { min: 2, max: 4, message: '请选择 %s - %s 项' },
dentical: { field: 'pwd_again', message: '两次密码不相同' }, //判断与再次输入号码内容相同
different: { field: 'username', message: '不能和username相同', },
digits: { message: '只能为数字' },
stringCase: { message: '必须大写', case: 'upper' },
remote: { url: 'remote.php', message: '用户名不可用' },
greaterThan: { value: 18, inclusive: true, message: '必须大于或等于18' },
lessThan: { value: 100, inclusive: false, message: '必须小于100' },
uri: {}, //判断网址
date: { format: 'yyyy-mm-dd ', message: '时间格式不正确' },
stringLength: { max: 250, message: '最多只能输入250字' },
},
callback: {
message: '请输入',
callback: function (value, validator, $field) {
return !(value == 0 || value == "");
}
},
}
}
})
$("#form").bootstrapValidator('addField', "#id", {
validators: {
notEmpty: {
message: '参数不能为空'
}
}
})