bootstrapValidator--表单校验
关于表单校验 要依次引入
<link rel="stylesheet" href="./bootstrap/css/bootstrap.min.css">
<!-- 表单校验 -->
<link rel="stylesheet" href="./bootstrap-validator/css/bootstrapValidator.min.css">
<script src="./jquery/jquery.min.js"></script>
<script src="./bootstrap/js/bootstrap.min.js"></script>
<script src="./bootstrap-validator/js/bootstrapValidator.min.js"></script>
<!-- id :和后面的校验匹配 -->
<form class="form-horizontal" id="addForm">
<div class="form-group">
<label for="name" class="col-sm-2 control-label">姓名:</label>
<div class="col-sm-10">
<input type="text" name="username" data-bv-notempty="true"
data-bv-notempty-message="不能为空" class="form-control" id="username" placeholder="">
</div>
</div>
<div class="form-group">
<label for="name" class="col-sm-2 control-label">性别:</label>
<div class="col-sm-10">
<!-- <input type="text" class="form-control" id="name" placeholder=""> -->
<label><input type="radio" name="sex" value="男">男</label>
<label><input type="radio" name="sex" value="女">女</label>
</div>
</div> <div class="form-group">
<label for="creditCard" class="col-sm-2 control-label">身份证:</label>
<div class="col-sm-10">
<input type="creditCard" name="creditCard" class="form-control" id="creditCard"
placeholder="">
</div>
</div>
<div class="form-group">
<label for="phone" class="col-sm-2 control-label">电话:</label>
<div class="col-sm-10">
<input type="phone" name="phone" class="form-control" id="phone" placeholder="">
</div>
</div> <div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">邮箱:</label>
<div class="col-sm-10">
<input type="text" name="email" class="form-control" id="inputEmail3" placeholder="">
</div>
</div>
<div class="form-group">
<label for="register" class="col-sm-2 control-label">状态:</label>
<div class="col-sm-10">
<!-- <input type="text" class="form-control" id="phone" placeholder=""> -->
<select name="addStatus" id="register" class="form-control">
<option value="">未注册</option>
<option value="">已注册</option>
<option value="">休学</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-6">
<button type="reset" class="btn btn-default pull-left">重置</button>
<button type="submit" class="btn btn-primary pull-right">保存</button>
</div>
</div>
</form>
$('#addForm').bootstrapValidator({
message: 'This value is not valid',
// 配置校验图标
feedbackIcons: {
valid: 'glyphicon glyphicon-ok', // 校验成功
invalid: 'glyphicon glyphicon-remove', // 校验失败
validating: 'glyphicon glyphicon-refresh' // 校验中
},
// 配置校验字段 (给input设置 name 值)
fields: {
username: {
message: '用户名验证失败',
validators: {
notEmpty: {
message: '用户名不能为空'
}
}
},
email: {
validators: {
// notEmpty: {
// message: '邮箱地址不能为空'
// }
regexp: { //正则表达式
// 邮箱
// regexp: /^\w+@\w+(\.[a-z]+){1,2}$/,
regexp: /^(\w+@\w+(\.[a-z]+){1,2}\;)*\w+@\w+(\.[a-z]+){1,2}$/,
message: '邮箱格式不正确'
},
}
},
phone: {
message: '电话验证失败',
validators: {
// notEmpty: {
// message: '电话不能为空'
// },
regexp: { //正则表达式
//*星号表示可以重复任意次,也就是可以有多个号码
// (13|15|18)\d{9}$ 最后一个用来匹配没有分号的号码
// 最后一个号码不能有分号
regexp: /^((13|15|18)\d{9}\;)*(13|15|18)\d{9}$/,
//以13,15,18开头的手机号,共11位,如果多个手机号中间用英文的;(分号)分开
message: '号码格式不正确'
},
}
},
creditCard: {
message: '身份证验证失败',
validators: {
notEmpty: {
message: '身份证不能为空'
},
regexp: { //正则表达式
// 身份证号码为15位或者18位,15位时全为数字,
// 18位前17位为数字,最后一位是校验位,可能为数字或字符X
regexp: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
message: '身份证格式不正确'
},
}
},
}
});
bootstrapValidator--表单校验的更多相关文章
- 表单校验插件(bootstrap-validator)
表单校验插件(bootstrap-validator) 参考文档 http://blog.csdn.net/nazhidao/article/details/51542508 http://blog. ...
- BootstrapValidator 表单验证超详细教程
一. 引入js 和css文件 在有jquery和bootstrap的页面里引入 bootstrapValidator.js bootstrapValidator.css 链接: https://pan ...
- 利用jquery.validate以及bootstrap的tooltip开发气泡式的表单校验组件
表单校验是页面开发中非常常见的一类需求,相信每个前端开发人员都有这方面的经验.网上有很多成熟的表单校验框架,虽然按照它们默认的设计,用起来没有多大的问题,但是在实际工作中,表单校验有可能有比较复杂的个 ...
- AngularJS 1.2.x 学习笔记(表单校验篇)
https://my.oschina.net/cokolin/blog/526911 摘要: 本文首发于 blog.csdn.net/vipshop_ebs/article/details/39472 ...
- angularJs表单校验(超级详细!!!)
html代码 <!DOCTYPE html> <html ng-app="angularFormCheckModule"> <head> < ...
- bootstrap+jQuery.validate表单校验
谈谈表单校验 这大概是一种惯例,学习前台后台最开始接触的业务都是用户注册和登录.现在社会坚持以人为本的理念,在网站开发过程同样如此.User是我们面对较多的对象,也是较核心的对象.最开始的用户注册和登 ...
- 关于jQuery表单校验的应用
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...
- php 表单校验函数库(判断email格式是否正确、http地址是否合法有效、手机号码是否合法)
/** * 表单校验函数库 */ /** * 判断email格式是否正确 * @param $email */ function is_email($email) { return strlen($e ...
- 关于jQuery表单校验
<style> .red{border: 1px solid red;} .wrong-tip{color: red;} </style> <form action=&q ...
- jQuery.validate表单校验+bootstrap
谈谈表单校验 这大概是一种惯例,学习前台后台最开始接触的业务都是用户注册和登录.现在社会坚持以人为本的理念,在网站开发过程同样如此.User是我们面对较多的对象,也是较核心的对象.最开始的用户注册和登 ...
随机推荐
- 【Jenkins、sonar】
1.Jenkins入门(一)安装Jenkins 2.Jenkins入门(二)部署java项目 3.Jenkins远程部署SpringBoot应用 4.配置sonar.jenkins进行持续审查 5.S ...
- Yii2中GridView
Yii2 GridView与dropdownList结合的用法 http://www.yiichina.com/tutorial/473 <?=$form->field($model, ' ...
- Delphi内建异常类 异常处理参考
标签: delphiexceptionwindowscasting编程integer 2012-05-19 12:53 2579人阅读 评论(0) 收藏 举报 分类: Delphi(96) [详细过程 ...
- B/S 和 C/S 架构软件
1.B/S架构: 通过C语言或java可以实现,使用B/S架构的软件,启动.打开应用和原生软件一样的效果. (正常浏览器打开的应用页面是有地址栏.菜单栏和标签栏的,但是通过配置可以关闭这些窗口,使B/ ...
- Openfire部署(一)
1.从官网下载openfire_4_1_4.tar.gz文件: 2.上传到linux上,解压缩 3.启动openfire [root@localhost opt]# cd openfire/bin [ ...
- git分布式版本控制系统权威指南学习笔记(三):简单了解git对象、head以及sha1sum
文章目录 git对象(简单了解) 对象是存在哪里的? head和master分支 上面的hash值怎么来的? git对象(简单了解) 每次提交都有tree.parent.author.committe ...
- 1、siege安装
1.下载最新版本的siege wget http://download.joedog.org/siege/siege-latest.tar.gz 2.解压并进入siege路径 tar -zxvf si ...
- 9、TestNG介绍与安装
介绍 TestNG是一个受JUnit和NUnit启发的测试框架,但引入了一些新功能,使其更加强大和易于使用,例如: 注释. 在任意大的线程池中运行你的测试,这些线程池有各种可用的策略(所有方法在他们自 ...
- ArabellaCPC 2019
链接:http://codeforces.com/gym/102263 A: 签到题:A * B . B: 题意:类似取石子游戏,每个人可以取max(1, n(当前剩余) - k)个,最后取完的人赢, ...
- Hyperledger:常见加密算法分类列表
算法原理查询:http://mathworld.wolfram.com 加密散列函数 (消息摘要算法,消息认证码,MD算法) Keyed-hash message authentication c ...