source:http://bv.doc.javake.cn/api/

BootstrapValidator is the best jQuery plugin to validate form fields, designed to use with Bootstrap 3.

<link rel="stylesheet" href="../vendor/bootstrap/css/bootstrap.css"/>
<link rel="stylesheet" href="../dist/css/bootstrapValidator.css"/>

<!-- Include the FontAwesome CSS if you want to use feedback icons provided by FontAwesome -->
<!--<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" />-->

<script type="text/javascript" src="../vendor/jquery/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="../vendor/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../dist/js/bootstrapValidator.js"></script>

  • <form id="tryitForm" class="form-horizontal">
    <div class="form-group">
    <label class="col-md-3 control-label">Full name</label>
    <div class="col-md-4">
    <input type="text" class="form-control" name="firstName" />
    </div>
    <div class="col-md-4">
    <input type="text" class="form-control" name="lastName" />
    </div>
    </div> <div class="form-group">
    <label class="col-md-3 control-label">Email address</label>
    <div class="col-md-6">
    <input type="text" class="form-control" name="email" />
    </div>
    </div> <div class="form-group">
    <label class="col-md-3 control-label">Gender</label>
    <div class="col-md-6">
    <div class="radio">
    <label><input type="radio" name="gender" value="male" /> Male</label>
    </div>
    <div class="radio">
    <label><input type="radio" name="gender" value="female" /> Female</label>
    </div>
    <div class="radio">
    <label><input type="radio" name="gender" value="other" /> Other</label>
    </div>
    </div>
    </div> <div class="form-group">
    <div class="col-md-offset-3 col-md-8">
    <button type="submit" class="btn btn-primary">Say hello</button>
    </div>
    </div>
    </form>
  • JS
<script>
$(document).ready(function() {
$('#tryitForm').bootstrapValidator({
fields: {
firstName: {
validators: {
notEmpty: {
message: 'The first name is required and cannot be empty'
}
}
},
lastName: {
validators: {
notEmpty: {
message: 'The last name is required and cannot be empty'
}
}
},
email: {
validators: {
notEmpty: {
message: 'The email address is required'
},
emailAddress: {
message: 'The input is not a valid email address'
}
}
},
gender: {
validators: {
notEmpty: {
message: 'The gender is required'
}
}
}
},
submitHandler: function(validator, form, submitButton) {
var fullName = [validator.getFieldElements('firstName').val(),
validator.getFieldElements('lastName').val()].join(' ');
$('#helloModal')
.find('.modal-title').html('Hello ' + fullName).end()
.modal();
}
});
});
</script>

BootstrapValidator demo的更多相关文章

  1. bootstrapValidator 使用(包含入门demo,常用方法,以及常用的规则)

    一   什么是bootstrapValidator?    -- 一个基于 jquery,boostrap 的表单验证框架....简单实用上手快,页面美观还过得去,不废话了,直接撸. 二  boots ...

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

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

  3. bootstrapValidator 表单验证

    官网下载地址:http://plugins.jquery.com/bootstrapValidator/ html代码 <!DOCTYPE html> <html> <h ...

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

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

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

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

  6. 黄聪: Bootstrap之Form表单验证神器: BootstrapValidator(转)

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

  7. bootstrapValidator表单验证插件

    bootstrapValidator——一个很好用的表单验证插件,再也不用手写验证规则啦! bootstrapValidator官方文档:http://bootstrapvalidator.votin ...

  8. Form表单验证神器: BootstrapValidator

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

  9. BootstrapValidator:表单验证神器

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

随机推荐

  1. playbacktask

    / ** 播放应用程序的头文件. 此文件是头文件,用于定义Playback应用程序的API和数据类型. @file PlaybackTsk.h @ingroup mIAPPPlay @note什么都没 ...

  2. 最近的一些JAVA基础知识

    1,关于判断两个值是否相等 equal 和==是有区别到 2,判断一个数组集合 List是否为空 这个不能用"==null或者equal"要用isEmpty() , 对于不等于加一 ...

  3. html5的导出表格功能

    最近遇到一个需要导出表格的需求,研究了一下nodeJs的excel模块及好多其他的插件,发现还是蛮复杂的,由于项目对于表格的要求不高,因此同事推荐了一种h5的表格导出生成方法,比较简单,在此记录一下 ...

  4. ES6(对象扩展)

    ES6(对象(object)新增特性) 1.简介表示法 o,k 为属性:这种为无方法的情况. 这种为有方法. 2.属性表达式 ES6中,[a]就是 b . 3.新增API 1.数组也是引用类型 2.O ...

  5. sql通配符+sql中查询条件包含下划线等通配符的写法

    一.SQL 通配符 在搜索数据库中的数据时,SQL 通配符可以替代一个或多个字符. SQL 通配符必须与 LIKE 运算符一起使用. 在 SQL 中,可使用以下通配符: 通配符 描述 % 替代一个或多 ...

  6. Go内建变量类型

    package main import ( "math/cmplx" "fmt" "math" ) //内建变量类型: // bool , ...

  7. HDU 1874 最直接的最短路径问题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1874 Problem Description 某省自从实行了很多年的畅通工程计划后,终于修建了很多路. ...

  8. hdu 4790 数学

    /* 题意:给你二个区间[a,b]和[c,d] 分别从中选一个数x和y使的(x+y)%p=m; 可以这样来求,先求出(0->b和0->d区间段的值)-(区间0->a-1和0-> ...

  9. java基础 4 继承(1)抽象类与接口的区别

    抽象类: 是用来捕捉子类的通用特性的,至少包含一个抽象方法,该抽象方法必须在子类中实现,由于抽象类没有抽象方法的具体实现,因此不能对抽象类进行实例化. 接口: 定义了一组方法,是抽象方法的集合,但是接 ...

  10. Netflix是什么,与Spring Cloud有什么关系

    说明:以下总结的观点不一定准确,但是是最好理解的. 1.首先,Netflix是一家做视频的网站,可以这么说该网站上的美剧应该是最火的. 2.Netflix是一家没有CTO的公司,正是这样的组织架构能使 ...