bootstrapValidator 常用的验证
$("#表单ID").bootstrapValidator({
message: 'This value is not valid',
excluded: [':disabled'],
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
name:{
validators:{
notEmpty: {
message: '必须输入或者必须选择'
},
stringLength : {
min : 2,
max : 25,
message : '长度2-25位字符'
}
}
}
}
}).on('success.form.bv', function (e) {
e.preventDefault();
//这里可以进行ajax提交
});
notEmpty: {
message: '必须输入或者必须选择'
}
digits : {
message : '字段必须是正整数'
}
greaterThan: {
value : 1,
message : '最小输入1'
}
lessThan: {
value : 100
message : '最大输入100'
}
regexp: {
regexp: /^[a-zA-Z0-9_]+$/,
message: '正则验证,这里验证只能输入大小写字母数字和下划线'
}
html 标签上添加验证,去掉最上面的fields部分
<input type="text" name="name" required data-bv-notempty-message="必须输入"
data-bv-stringlength="true" data-bv-stringlength-min="2" data-bv-stringlength-max="15" data-bv-stringlength-message="长度2-15位"
pattern="^[0-9]{8}$" data-bv-regexp-message="正则验证不正确">
<select data-bv-choice="true" data-bv-choice-min="1" data-bv-choice-max="10" data-bv-choice-message="最少选择1条记录 最多选择10条记录">
<option><option>
......
<select>
<input type="radio" name="sex" value="男" required data-bv-notempty-message="必须选择性别">
<input type="radio" name="sex" value="女">
<!--这里只需要在第一个标签上添加验证代码即可 如果全部添加上验证代码也是没有问题。-->
js形式和html形式可以混着用
bootstrapValidator 常用的验证的更多相关文章
- bootstrapValidator常用验证规则总结
bootstrapValidator常用验证规则总结 一 .bootstrapValidator引入 在使用bootstrapValidator前我们需要引入bootstrap和bootstrapVa ...
- bootstrapvalidator常用验证解析和使用
学这个博主的:https://www.cnblogs.com/wang-kai-xuan/p/11031733.html BootStrapValidator表单验证插件的学习和使用 引入标签 ...
- BootstrapValidator 表单验证超详细教程
一. 引入js 和css文件 在有jquery和bootstrap的页面里引入 bootstrapValidator.js bootstrapValidator.css 链接: https://pan ...
- Struts2 验证框架 validation.xml 常用的验证规则
validation.xml 的命名规则和放置路径: 文件名:<ActionClassName>-validation.xml <ActionClassName>就是要验证的A ...
- c#基类 常用数据验证的封装,数字,字符,邮箱的验证
#region 常用数据验证的封装,数字字符的验证 /// <summary> /// 常用数据验证的封装,数字字符的验证 /// </summa ...
- java 常用的验证方法帮助类
import java.text.ParseException; import java.util.Collection; import java.util.Map; /** * 常用的验证方法帮助类 ...
- Swift - 正则表达式的使用(附用户名、邮箱、URL等常用格式验证)
Swift虽然是一个新出的语言,但却不提供专门的处理正则的语法和类.所以我们只能使用古老的NSRegularExpression类进行正则匹配. 即先接受一个正则表达式的字符串,由此生成NSRegul ...
- php常用的验证
<?php namespace Vendor\Func; /** * 常用的验证 * Class Verify * @package Vendor\Func */ class Verify { ...
- BootStrapValidator表单验证插件的学习和使用
BootStrapValidator表单验证插件的学习和使用 引入标签 <script type="text/javascript" src="https://cd ...
随机推荐
- github 工具命令集
- Hibernate总结(转)
原文:http://blog.csdn.net/yuebinghaoyuan/article/details/7300599 那我们看一下hibernate中整体的内容: 我们一一介绍其中的内容. H ...
- Impala 安装笔记3一impala安装
安装impala之前,确认满足Cloudera Impala Requirements中要求的所有条件: Supported Operating Systems Supported CDH Versi ...
- iOS 开发中的一些注意点(安全、当前语言、时间格式化)
1.重复运行项目,不重复构建项目(来自Heath Borders) 假如你一直在不停地调试同一个问题,你可以在不重复构建的情况下运行你的APP,这样:“Product>Perform Actio ...
- Vue一次性简洁明了引入所有公共组件
使用场景 -在开发过程中,往往会有很多自己定义公用组件,我们通过import 导入,components挂载到实例上就行,项目刚开始还好,但是随着项目迭代,组件越来越多,同一个组件不同的方式用需要重复 ...
- hadoop 添加,删除节点
http://www.cnblogs.com/tommyli/p/3418273.html
- html5--3.9 input元素(8)
html5--3.9 input元素(8) 学习要点 input元素及其属性 input元素 用来设置表单中的内容项,比如输入内容的文本框,按钮等 不仅可以布置在表单中,也可以在表单之外的元素使用 i ...
- SSL peer shut down incorrectly
这个问题通常出现在Android Studio更新失败的时候, 原因是download http://services.gradle.org/distributions/gradle-2.2-all. ...
- 1、VGG16 2、VGG19 3、ResNet50 4、Inception V3 5、Xception介绍——迁移学习
ResNet, AlexNet, VGG, Inception: 理解各种各样的CNN架构 本文翻译自ResNet, AlexNet, VGG, Inception: Understanding va ...
- DNS多出口分析
DNS多出口分问题现象:当dns解析出的ip非域名的本地覆盖组,则怀疑是DNS多出口或者DNS劫持.接下来判断该ip是否为网宿ip,如果不是,则是劫持问题,走劫持流程进行反馈.如果是网宿ip,则用以下 ...