ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 表单验证 bootstrapValidator 参考文档: [http://bv.doc.javake.cn/validators/](http://bv.doc.javake.cn/validators/) ![](https://box.kancloud.cn/2016-06-29_57738492456c5.png) ## 基本模式 ``` <form id="registrationForm" class="form-horizontal"> <div class="form-group"> <label class="col-lg-3 control-label">Username</label> <div class="col-lg-5"> <input type="text" class="form-control" name="username" /> </div> </div> </form> <script> require(['validator'],function($){ $('#registrationForm').bootstrapValidator({ //图标 feedbackIcons: { valid: 'glyphicon glyphicon-ok',//通过 invalid: 'glyphicon glyphicon-remove',//无效 validating: 'glyphicon glyphicon-refresh'//有效 }, fields: { username: { message: '用户名错误', validators: { notEmpty: { message: '用户名不能为空' }, stringLength: { min: 6, max: 30, message: '用户名长度在6-30之间' }, regexp: { regexp: /^[a-zA-Z0-9_]+$/, message: '用户名格式错误' } } }, } }); }); </script> ```