企业🤖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> ```