BootStrapValidator校验方式

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

BootStrapValidator校验方式

青衣故人   2020-05-15 我要评论

做输入校验的时候如果你前端框架用的是bootstrap的话,首推bootstrapValidator校验方式,具体流程如下:

一、下载,导入js文件

<link type="text/css" rel="stylesheet" href="${ctx}/components/validate/css/bootstrapValidator.css" />
<script type="text/javascript" src="${ctx}/components/validate/js/bootstrapValidator.js"></script>
<script type="text/javascript" src="${ctx}/components/validate/js/language/zh_CN.js"></script>

二、

$(表单id:)({
  message:'这里写默认提示信息';
  feedbackIcons:{
          valid:'glyphicon glyphicon-ok',
          invalid:'glyphicon glyphicon-remove',
          validating:'glyphicon glyphicon-refresh'
        },
   fields: {
            inputName: {
            validators: {
              notEmpty: {
                message: '时间不能为空'
              },
              regexp: {
                 regexp: /^[0-9]+$/ ,
                 message: '时间由数字组成'
               },
                 stringLength: {
                min: 1,
                max: 20,
                message: '角色名长度必须在1到20之间'
              }
          }
      }
   }
   )

网上有各种验证,当然有自定义验证,如上例中的时间由数字组成。

以上所述是小编给大家介绍的BootStrapValidator校验方式,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们