bootstrapValidator使用总结
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使用总结的更多相关文章
- bootstrapvalidator+bootstrap-select select无法校验问题解决方法
$("#form_user_input") .bootstrapValidator( { message : 'This value is not valid', excluded ...
- Bootstrap表单验证插件bootstrapValidator使用方法整理
插件介绍 先上一个图: 下载地址:https://github.com/nghuuphuoc/bootstrapvalidator 使用方法:http://www.cnblogs.com/huangc ...
- JS组件系列——Form表单验证神器: BootstrapValidator
前言:做Web开发的我们,表单验证是再常见不过的需求了.友好的错误提示能增加用户体验.博主搜索bootstrap表单验证,搜到的结果大部分都是文中的主题:bootstrapvalidator.今天就来 ...
- bootstrapvalidator校验、校验清除重置
//保存 function saveAdmin(){ //开启验证 $('#saveadmin_form').data('bootstrapValidator').validate(); if(!$( ...
- bootstrapValidator.js,最好用的bootstrap表单验证插件
前言:做Web开发的我们,表单验证是再常见不过的需求了.友好的错误提示能增加用户体验.博主搜索bootstrap表单验证,搜到的结果大部分都是文中的主题:bootstrapvalidator.今天就来 ...
- jQuery 实现bootstrapValidator下的全局验证
前置: 引入jQuery.bootstrap.bootstrapValidator 问题描述: 项目中要求所有的表单输入框中都不能输入&符号.没有在bootstrap中找到有方法可用,只能自己 ...
- bootstrapValidator.js 做表单验证
有这样的一个场景,我们在提交form表单的时候 可能要做一些验证,比如判断是不是为空,电话的格式验证,邮箱的格式验证等等,手写起来也是可以得. 但是今天我介绍一个bootstrap插件简化开发.就是b ...
- 【bootstrapValidator 不验证】使用bootstrapValidator 验证效果不起作用
虽然在页面ready的时候 就绑定了验证表单 ,但是在点击提交按钮之后 依旧没有验证的效果 . 那就在提交按钮的点击事件中 添加一句话: $(document).ready( function () ...
- bootstrap-validator验证问题总结
bootstrap-validator是一个优秀的验证器,使用中遇到如下问题,总结如下: 1.<button type="submit" name="submit2 ...
- BootstrapValidator验证表单用法
引入文件 <link rel="stylesheet" href="css/bootstrap.css"/> <link rel=" ...
随机推荐
- hdu 6380
#include<bits/stdc++.h> #define in(a) scanf("%d",&a) using namespace std; struct ...
- 搭建 consul 集群
=============================consul 命令行工具=============================consul 支持 Windows/Linux 等多种平台, ...
- ETL脚本的版本管理方法和 SourceTree 使用
=============================使用git管理Kettle 作业的一个注意=============================之前 ETL 作业是用 svn 管理的, ...
- windows10 下使用Pycharm2016 基于Anaconda3 Python3.6 安装Mysql驱动总结
本文记录:在PyCharm2016.3.3 中基于Anaconda3 Python3.6版本安装Python for Mysql驱动.尝试了安装Mysql-Connector成功,但是连接数据库时驱动 ...
- 【python小练】图片爬虫之BeautifulSoup4
Python3用不了Scrapy! Python3用不了Scrapy! Python3用不了Scrapy! [重要的事情说三遍,据说大神们还在尝试把scrapy移植到python3,特么浪费我半个小时 ...
- JavaScript面试技巧(三):开发环境、运行环境
一.开发环境 1 介绍 2.IDE 3 .git - 4.模块化 - AMD CommonJS 5.构建工具 安装nodejs 安装webpack 配置webpack 使用jquery 压缩JS 6. ...
- python 的基础 学习 第七天 is id 编码的补充
1,== 两个等号比较的是数值,is比较的是内存地址.print(id())查看的内存地址. 小数据池只存在于数字与字符串中,数字 是 -5^^256,是为了节省空间. 字符串1,如果含有特殊字符 ...
- linux 根据Pid获取 进程内容
ps -ef | grep 753 | grep -v 'grep' | awk '{print $NF}'
- 自制rpm包
参考自:https://blog.csdn.net/u010384744/article/details/80929319 https://blog.csdn.net/samxx8/article/d ...
- mysql 查询优化 ~ 优化基础补充
一 简介:此文章是对于 sql通用基础的补充说明 二 虚拟列: mysql虚拟列是mysql5.7的新特性,对于函数计算形成的结果可作为虚拟列,并可以对虚拟列添加索引,这样就能加速sql的运行,不过有 ...