bootstrapValidator校验
先引进<script src="/Scripts/jquery-1.11.1.js"></script><script src="/bootstrap/js/bootstrap.min.js"></script><link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet" /><script src="/bootstrapValidator/js/bootstrapValidator.min.js"></script><link href="/bootstrapValidator/css/bootstrapValidator.min.css" rel="stylesheet" />
1.初级用法
$(function () { $('form').bootstrapValidator({ message: 'This value is not valid',
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
}, fields: { username: { message: '用户名验证失败', validators: { notEmpty: { message: '用户名不能为空' } } }, email: { validators: { notEmpty: { message: '邮箱地址不能为空' } } } } }); });2.中级用法$(function () { $('form').bootstrapValidator({ message: 'This value is not valid', feedbackIcons: { valid: 'glyphicon glyphicon-ok', invalid: 'glyphicon glyphicon-remove', validating: 'glyphicon glyphicon-refresh' }, fields: { username: { message: '用户名验证失败', validators: { notEmpty: { message: '用户名不能为空' }, stringLength: { min: 6, max: 18, message: '用户名长度必须在6到18位之间' }, regexp: { regexp: /^+$/, message: '用户名只能包含大写、小写、数字和下划线' } } }, email: { validators: { notEmpty: { message: '邮箱不能为空' }, emailAddress: { message: '邮箱地址格式有误' } } } } }); });
页:
[1]