一个例子

  

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<jsp:include page="/views/common/JsAndCss.jsp"/>
<title>form表单的校验</title>
</head>
<body> <div class="container">
<div style="" class="content-center w-500 m-t40 h-600"> <!-- class都是bootstrap定义好的样式,验证是根据input中的name值 -->
<form id="defaultForm" class="form-horizontal">
<div class="form-group">
<label class="control-label col-md-2">用户名</label>
<div class="col-md-10">
<input class="form-control" name="username" type="text" placeholder="请输入用户名">
</div>
</div>
<div class="form-group">
<label class="control-label col-md-2">密码</label>
<div class="col-md-10">
<input class="form-control" name="password" type="password" placeholder="请输入密码">
</div>
</div>
<div class="form-group">
<label class="control-label col-md-2">邮箱</label>
<div class="col-md-10">
<input class="form-control" name="email" type="text" placeholder="请输入邮箱">
</div>
</div>
<div class="form-group">
<input class="btn btn-success col-md-4 col-md-offset-4" name="submit" type="submit" value="提交">
</div>
</form>
</div>
</div>
<script type="text/javascript"> $(document).ready(function(){
$("#defaultForm").bootstrapValidator({
message:"不进行校验的值!",
feedbackIcons:{//输入不同的状态,显示的图片的样式不同
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields:{//校验
username:{//键名username和name中的值对应
validators:{
notEmpty:{//非空校验
message:"用户名称不能为空"
},
stringLength:{//长度校验
min:6,
max:10,
message:"用户名长度在6-10位之间"
},
regexp:{//使用正则表达式
regexp:getReg().num,
message:"只能使用数字"
},
/*identical: {//相同
field: 'password', //需要进行比较的input name值
message: '两次密码不一致'
},
different: {//不能和用户名相同
field: 'username',//需要进行比较的input name值
message: '不能和用户名相同'
},*/
}
},
password:{
validators:{
notEmpty:{
message:"密码不能为空"
}
}
},
email:{
validators:{
notEmpty:{
message:"邮箱地址不能为空"
},
emailAddress:{//邮箱地址的校验
message:"邮箱格式不正确"
} }
} } }) }) </script>
</body> </html>

boostrapvalidator的更多相关文章

  1. 关于boostrapValidator动态添加字段(addField)验证的bug

    每次码博客,都觉得自己怀才不遇,哎~脑袋有瑕疵,文笔拿不粗手,就直接上干货吧. 在使用boostrapValidator这个验证插件的时候,如果某一个字段是动态添加来的,我们需要调用方法:addFie ...

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

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

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

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

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

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

  5. 双重保险——前端bootstrapValidator验证+后台MVC模型验证

    我们在前端使用BoostrapValidator插件验证最基本的格式要求问题,同时在后台中,使用MVC特有的模型验证来做双重保险.对于boostrapValidator我就不说了,具体请看<bo ...

  6. Form表单验证神器: BootstrapValidator

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

  7. BootstrapValidator:表单验证神器

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

  8. Bootstrap之Form表单验证神器: BootstrapValidator(转)

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

随机推荐

  1. 浅谈Linux Kernel 中循环链表的实现

    前阵子在弄缓存的时候,我们需要将qemu对于磁盘镜像文件写请求串成一个链表,最终将这个链表里面的写请求全部刷回到镜像文件里面,那么我们便需要一个强健,可靠的链表的接口,于是我们仿照Linux 2.4. ...

  2. 并不对劲的字符串专题(三):Trie树

    据说这些并不对劲的内容是<信息学奥赛一本通提高篇>的配套练习. 并不会讲Trie树. 1.poj1056-> 模板题. 2.bzoj1212-> 设dp[i]表示T长度为i的前 ...

  3. 并不对劲的AC自动机

    这像是能解决所有问题的样子(并不).AC自动机之所以叫AC自动机是因为它能解决所有AC自动机的题. 其实只能解决的是很多模式串匹配一个母串的问题. 把kmp中的next数组得到下一次跳转的位置看成特殊 ...

  4. 腾讯API

    相关文档: API列表  腾讯开放平台联调工具集  公共返回码说明 SDK下载

  5. INT_PTR数据类型

    A signed integer type for pointer precision. Use when casting a pointer to an integer to perform poi ...

  6. E20170520-ts

    regexp  n. 正则表达式 metacharacter メタ文字 元字符 quote   vt. 引述,引用; escape  v. 逃脱; 逃离;   n. 逃走; 逃跑工具或方法;  reg ...

  7. Douglas-Peucker 轨迹压缩算法

    算法的基本思路是:     对每一条曲线的首末点虚连一条直线,求所有点与直线的距离,并找出最大距离值dmax ,用dmax与限差D相比:     若dmax <D,这条曲线上的中间点全部舍去; ...

  8. python 面向对象六 动态添加方法 __slots__限制动态添加方法

    一.动态添加属性 >>> class Student(object): pass >>> st = Student() >>> st.name = ...

  9. logstsh | logstash-input-jdbc 启动错误收集

    1: Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :excepti ...

  10. Qt之界面(自定义标题栏、无边框、可移动、缩放)

    效果 自定义标题栏 titleBar.h #ifndef TITLEBAR_H #define TITLEBAR_H #include <QLabel> #include <QPus ...