1.根据条件动态增删检查条件

参考文章:https://blog.csdn.net/sxlzs_/article/details/78211928

#去除某字段的验证

$("#formResource").bootstrapValidator('removeField', 'permission');

#增加某字段的验证

$("#formResource").bootstrapValidator("addField", "permission", {
validators : {
notEmpty : {
message : '数据标识不能为空'
}
}
});

2.select等值会发生变化时处理

sjklx : {
trigger : 'change',
validators : {
notEmpty : {
message : '数据库类型不能为空'
}
}
}

3.输入字符长度控制,添加正则校验

以输入密码为例:

pass: {
validators: {
stringLength: {
min: 6,
max: 18,
message: '密码长度至少6位'
},
regexp: {
regexp: /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,18}$/,
message: '必须含有大写字母,小写字母和数字'
}
}
}

4.两次密码校验

pass: {
validators: {
stringLength: {
min: 6,
max: 18,
message: '密码长度至少6位'
},
regexp: {
regexp: /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,18}$/,
message: '必须含有大写字母,小写字母和数字'
}
}
},
// 密码确认
passConfirm: {
message: '密码确认验证失败',
validators: {
identical: {
field: 'pass',
message: '两次密码不相同'
}
}
}

4.ip 校验

ip: {
validators: {
ip: {
message: '请输入正确的IP地址'
}
}
}

5. emailAddress校验

mail: {
validators: {
emailAddress: {
message: '请输入正确的Email地址'
}
}
}

6. between:值范围校验

level: {
validators: {
between: {
message: '输入值必须在1到10之间'
}
}
}

7.base64校验

base64Test: {
validators: {
base64: {
message: '不是合法的base64编码'
}
}
},

7.身份证校验

creditCardTest: {
validators: {
creditCard: {
message: '不是合法的身份证'
}
}
},

8.date日期校验

dateTest: {
validators: {
date: {
message: '不是合法的日期'
}
}
}

9.numeric校验

numericTest: {
validators: {
numeric: {
message: '不是合法的数字'
}
}
}

9.uri校验

dateTest: {
validators: {
uri: {
message: '不是合法的URI'
}
}
}

10.电话号码校验

phoneTest: {
validators: {
phone: {
message: '不是合法的电话'
}
}
}

11.校验范围:隐藏域(:hidden)、禁用域(:disabled)、那啥域(:not(visible))

bootstrap默认不对上述三种类型进行校验,如果需要改变,见下:

$('#form').bootstrapValidator({
message: '您的输入有误',
excluded: [":disabled"],
fields: {
zjxh: {
validators: {
notEmpty: {
message: '闸机型号不能为空'
}
}
}
}
});

12.input=file校验

zp : {
trigger : 'change',
validators : {
notEmpty : {
message : '照片不能为空'
},
regexp : {
regexp : /jpg$/,
message : '格式必须为.jpg'
}
}
}

bootstrapValidator使用总结的更多相关文章

  1. bootstrapvalidator+bootstrap-select select无法校验问题解决方法

    $("#form_user_input") .bootstrapValidator( { message : 'This value is not valid', excluded ...

  2. Bootstrap表单验证插件bootstrapValidator使用方法整理

    插件介绍 先上一个图: 下载地址:https://github.com/nghuuphuoc/bootstrapvalidator 使用方法:http://www.cnblogs.com/huangc ...

  3. JS组件系列——Form表单验证神器: BootstrapValidator

    前言:做Web开发的我们,表单验证是再常见不过的需求了.友好的错误提示能增加用户体验.博主搜索bootstrap表单验证,搜到的结果大部分都是文中的主题:bootstrapvalidator.今天就来 ...

  4. bootstrapvalidator校验、校验清除重置

    //保存 function saveAdmin(){ //开启验证 $('#saveadmin_form').data('bootstrapValidator').validate(); if(!$( ...

  5. bootstrapValidator.js,最好用的bootstrap表单验证插件

    前言:做Web开发的我们,表单验证是再常见不过的需求了.友好的错误提示能增加用户体验.博主搜索bootstrap表单验证,搜到的结果大部分都是文中的主题:bootstrapvalidator.今天就来 ...

  6. jQuery 实现bootstrapValidator下的全局验证

    前置: 引入jQuery.bootstrap.bootstrapValidator 问题描述: 项目中要求所有的表单输入框中都不能输入&符号.没有在bootstrap中找到有方法可用,只能自己 ...

  7. bootstrapValidator.js 做表单验证

    有这样的一个场景,我们在提交form表单的时候 可能要做一些验证,比如判断是不是为空,电话的格式验证,邮箱的格式验证等等,手写起来也是可以得. 但是今天我介绍一个bootstrap插件简化开发.就是b ...

  8. 【bootstrapValidator 不验证】使用bootstrapValidator 验证效果不起作用

    虽然在页面ready的时候 就绑定了验证表单 ,但是在点击提交按钮之后 依旧没有验证的效果 . 那就在提交按钮的点击事件中 添加一句话: $(document).ready( function () ...

  9. bootstrap-validator验证问题总结

    bootstrap-validator是一个优秀的验证器,使用中遇到如下问题,总结如下: 1.<button type="submit" name="submit2 ...

  10. BootstrapValidator验证表单用法

    引入文件 <link rel="stylesheet" href="css/bootstrap.css"/> <link rel=" ...

随机推荐

  1. redis的安装与简单使用

    redis的安装与简单使用: Redis简介: redis的应用场景: 1.关于关系型数据库和nosql数据库 关系型数据库是基于关系表的数据库,最终会将数据持久化到磁盘上,而nosql数据     ...

  2. 11-SQLServer的事务、存储过程和触发器

    一. 事务 在SQLServer中,每条SQL语句,默认就是一条隐式的事务,但是如果我们需要一组SQL语句,那么就需要采用SQLServer提供的特有的标记 来声明事务的开始.提交和回滚了. 事务的开 ...

  3. Android的Device File Explorer刷新文件

    不知道为什么,右键点sync不起作用,必须点一下列表中的设备,才可以.

  4. SpringBoot入门笔记(三)、热加载

    1.配置热加载环境,在pom.xml添加如下代码 <build> <!--springloader plugin --> <plugins> <plugin& ...

  5. sql server中的merge

    http://www.cnblogs.com/CareySon/archive/2012/03/07/2383690.html 简介 Merge关键字是一个神奇的DML关键字.它在SQL Server ...

  6. 二十、Linux 进程与信号---非局部跳转

    20.1 setjmp 和 longjmp 函数 20.1.1 函数介绍 #include <setjmp.h> int setjmp(jmp_buf env); 函数功能:设置非局部跳转 ...

  7. Js JSON.stringify()与JSON.parse()与eval()详解及使用案例

    (1)JSON.parse函数 作用:将json字符串转换成json对象. 语法:JSON. parse(text[,reviver]). 参数:text  必须:一个有效的json字符串. revi ...

  8. 运行APP显示两个APP图标,一个打不开,删除一个后,另一个也会消失。

    可能原因:你添加了两个intent-filter 的LAUNCHER 事件,这种情况尤其在一个项目多个module的时候容易出现 <intent-filter>               ...

  9. C - Alphabetic Removals

    题目链接: You are given a string ss consisting of nn lowercase Latin letters. Polycarp wants to remove e ...

  10. Flask里面的cookie的基本操作

    #cookie相关操作,依赖于make_response #调用cookie依赖request模块 from flask import Flask,make_response,request #建立对 ...