bootstrap validator 使用示例

时间:2022-05-04
本文章向大家介绍bootstrap validator 使用示例,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
$('.form-horizontal').bootstrapValidator({
                 message : 'This value is not valid',
                 feedbackIcons : {
                     valid : 'glyphicon glyphicon-ok',
                     invalid : 'glyphicon glyphicon-remove',
                     validating : 'glyphicon glyphicon-refresh'
                 },
                 fields : {
                     "coachName" : {
                         validators : {
                             notEmpty : {
                                 message : '请输出教练名'
                             },
                             stringLength : {
                                 min : 2,
                                 max : 16,
                                 message : '不能低于2且不能超过16位'
                             },
                             regexp : {
                                 regexp : /^[a-zA-Z0-9u4e00-u9fa5]+$/,
                                 message : '不能包含特殊字符'
                             }
                         }
                     },
                     "phone" : {
                         validators : {
                             notEmpty : {
                                 message : '请输入手机号码'
                             },
                             regexp : {
                                 regexp : /^0?1[3|4|5|8][0-9]d{8}$/,
                                 message : '无效的手机号码'
                             }
                         }
                     },
                     "introduce" : {
                         validators : {
                             notEmpty : {
                                 message : '请输入健身店介绍'
                             },
                             stringLength : {
                                 min : 1,
                                 max : 256,
                                 message : '长度不能超过256'
                             }
                         }
                     }
                 }
             });