$("#表单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 常用的验证的更多相关文章

  1. bootstrapValidator常用验证规则总结

    bootstrapValidator常用验证规则总结 一 .bootstrapValidator引入 在使用bootstrapValidator前我们需要引入bootstrap和bootstrapVa ...

  2. bootstrapvalidator常用验证解析和使用

    学这个博主的:https://www.cnblogs.com/wang-kai-xuan/p/11031733.html BootStrapValidator表单验证插件的学习和使用 引入标签     ...

  3. BootstrapValidator 表单验证超详细教程

    一. 引入js 和css文件 在有jquery和bootstrap的页面里引入 bootstrapValidator.js bootstrapValidator.css 链接: https://pan ...

  4. Struts2 验证框架 validation.xml 常用的验证规则

    validation.xml 的命名规则和放置路径: 文件名:<ActionClassName>-validation.xml <ActionClassName>就是要验证的A ...

  5. c#基类 常用数据验证的封装,数字,字符,邮箱的验证

    #region 常用数据验证的封装,数字字符的验证       /// <summary>       /// 常用数据验证的封装,数字字符的验证       /// </summa ...

  6. java 常用的验证方法帮助类

    import java.text.ParseException; import java.util.Collection; import java.util.Map; /** * 常用的验证方法帮助类 ...

  7. Swift - 正则表达式的使用(附用户名、邮箱、URL等常用格式验证)

    Swift虽然是一个新出的语言,但却不提供专门的处理正则的语法和类.所以我们只能使用古老的NSRegularExpression类进行正则匹配. 即先接受一个正则表达式的字符串,由此生成NSRegul ...

  8. php常用的验证

    <?php namespace Vendor\Func; /** * 常用的验证 * Class Verify * @package Vendor\Func */ class Verify { ...

  9. BootStrapValidator表单验证插件的学习和使用

    BootStrapValidator表单验证插件的学习和使用 引入标签 <script type="text/javascript" src="https://cd ...

随机推荐

  1. 使用官方Android-support-v7在低版本上使用ActionBarActivity

    昨天晚上更新了下Android SDK Manager,发现Extras下的Android Support Library已经更新到19.1了,上网一查原来是sdk\extras\android\su ...

  2. 对于URL中文和特殊字符的处理方法

    1.中文的处理方法 NSString* string1 = @"https://www.cloudsafe.com/文件夹"; NSString* string2 = [strin ...

  3. laravel基础课程---2、Laravel配置文件、路由及php artisan(php artisan是什么)

    laravel基础课程---2.Laravel配置文件.路由及php artisan(php artisan是什么) 一.总结 一句话总结: PHP工具匠:php artisan,其实本身就是一些PH ...

  4. 如何查看智能手机的IP地址

      1.  外网IP IP地址可简单分为两类.外网IP或称公网IP是用来在Internet上唯一标识你的设备的.如果你通过GPRS或者3G技术接入互联网的话(通过运营商网络),那么你也可以通过下面的方 ...

  5. 从Inception v1,v2,v3,v4,RexNeXt到Xception再到MobileNets,ShuffleNet,MobileNetV2

    from:https://blog.csdn.net/qq_14845119/article/details/73648100 Inception v1的网络,主要提出了Inceptionmodule ...

  6. 重装系统后texstudio拼写检查不工作

    重装texstudio还是不行. 后来发现是重装系统后用户名和以前的系统用户明不一样,导致系统盘里的用户文件夹路径不一样.而texstudio的字典存放在用户路径文件夹下 C:\Users\xxx\A ...

  7. distutils 打包setup.py

    from distutils.core import setup setup(name='hello', version='1.0', description='test example', auth ...

  8. CF 809D Hitchhiking in the Baltic States——splay+dp

    题目:http://codeforces.com/contest/809/problem/D 如果值是固定的,新加入一个值,可以让第一个值大于它的那个长度的值等于它. 如今值是一段区间,就对区间内的d ...

  9. 如何更快更好的写出cnblog博客?windows live writer推荐

    之前总是会羡慕网上那些技术牛人的博客都写的那么给力,后来一搜发现还是有工具可用的. 这里就推荐一款写博客的"神器",Windows Live Writer (Get It Now! ...

  10. Winform中ComBox大小设置

    combox,listview等一些控件的外观会由于字体大小的改变而改变.修改字体的大小宽度自动变化