- 浏览: 217842 次
- 性别:
- 来自: 吉林
文章分类
最新评论
-
sunfeizhi:
very good!
jquery 鼠标右键事件、左键单击事件判定 -
liuchang615270:
...
jquery 鼠标右键事件、左键单击事件判定 -
applett:
ps:
jquery实现新浪微博的表情插件 -
applett:
jquery实现新浪微博的表情插件 -
shenlm203:
sublime 最新安装及插件推荐可以参看: https:// ...
sublime text 2使用心得汇总
var Validator = {
isEmail : function(s) {
return this.test(s, '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$');
},
isAbsUrl : function(s) {
return this.test(s, '^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+\\/?.*$');
},
isSize : function(s) {
return this.test(s, '^[0-9]+(%|in|cm|mm|em|ex|pt|pc|px)?$');
},
isId : function(s) {
return this.test(s, '^[A-Za-z_]([A-Za-z0-9_])*$');
},
isEmpty : function(s) {
var nl, i;
if (s.nodeName == 'SELECT' && s.selectedIndex < 1)
return true;
if (s.type == 'checkbox' && !s.checked)
return true;
if (s.type == 'radio') {
for (i=0, nl = s.form.elements; i<nl.length; i++) {
if (nl[i].type == "radio" && nl[i].name == s.name && nl[i].checked)
return false;
}
return true;
}
return new RegExp('^\\s*$').test(s.nodeType == 1 ? s.value : s);
},
isNumber : function(s, d) {
return !isNaN(s.nodeType == 1 ? s.value : s) && (!d || !this.test(s, '^-?[0-9]*\\.[0-9]*$'));
},
test : function(s, p) {
s = s.nodeType == 1 ? s.value : s;
return s == '' || new RegExp(p).test(s);
}
};
var AutoValidator = {
settings : {
id_cls : 'id',
int_cls : 'int',
url_cls : 'url',
number_cls : 'number',
email_cls : 'email',
size_cls : 'size',
required_cls : 'required',
invalid_cls : 'invalid',
min_cls : 'min',
max_cls : 'max'
},
init : function(s) {
var n;
for (n in s)
this.settings[n] = s[n];
},
validate : function(f) {
var i, nl, s = this.settings, c = 0;
nl = this.tags(f, 'label');
for (i=0; i<nl.length; i++)
this.removeClass(nl[i], s.invalid_cls);
c += this.validateElms(f, 'input');
c += this.validateElms(f, 'select');
c += this.validateElms(f, 'textarea');
return c == 3;
},
invalidate : function(n) {
this.mark(n.form, n);
},
reset : function(e) {
var t = ['label', 'input', 'select', 'textarea'];
var i, j, nl, s = this.settings;
if (e == null)
return;
for (i=0; i<t.length; i++) {
nl = this.tags(e.form ? e.form : e, t[i]);
for (j=0; j<nl.length; j++)
this.removeClass(nl[j], s.invalid_cls);
}
},
validateElms : function(f, e) {
var nl, i, n, s = this.settings, st = true, va = Validator, v;
nl = this.tags(f, e);
for (i=0; i<nl.length; i++) {
n = nl[i];
this.removeClass(n, s.invalid_cls);
if (this.hasClass(n, s.required_cls) && va.isEmpty(n))
st = this.mark(f, n);
if (this.hasClass(n, s.number_cls) && !va.isNumber(n))
st = this.mark(f, n);
if (this.hasClass(n, s.int_cls) && !va.isNumber(n, true))
st = this.mark(f, n);
if (this.hasClass(n, s.url_cls) && !va.isAbsUrl(n))
st = this.mark(f, n);
if (this.hasClass(n, s.email_cls) && !va.isEmail(n))
st = this.mark(f, n);
if (this.hasClass(n, s.size_cls) && !va.isSize(n))
st = this.mark(f, n);
if (this.hasClass(n, s.id_cls) && !va.isId(n))
st = this.mark(f, n);
if (this.hasClass(n, s.min_cls, true)) {
v = this.getNum(n, s.min_cls);
if (isNaN(v) || parseInt(n.value) < parseInt(v))
st = this.mark(f, n);
}
if (this.hasClass(n, s.max_cls, true)) {
v = this.getNum(n, s.max_cls);
if (isNaN(v) || parseInt(n.value) > parseInt(v))
st = this.mark(f, n);
}
}
return st;
},
hasClass : function(n, c, d) {
return new RegExp('\\b' + c + (d ? '[0-9]+' : '') + '\\b', 'g').test(n.className);
},
getNum : function(n, c) {
c = n.className.match(new RegExp('\\b' + c + '([0-9]+)\\b', 'g'))[0];
c = c.replace(/[^0-9]/g, '');
return c;
},
addClass : function(n, c, b) {
var o = this.removeClass(n, c);
n.className = b ? c + (o != '' ? (' ' + o) : '') : (o != '' ? (o + ' ') : '') + c;
},
removeClass : function(n, c) {
c = n.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)"), ' ');
return n.className = c != ' ' ? c : '';
},
tags : function(f, s) {
return f.getElementsByTagName(s);
},
mark : function(f, n) {
var s = this.settings;
this.addClass(n, s.invalid_cls);
this.markLabels(f, n, s.invalid_cls);
return false;
},
markLabels : function(f, n, ic) {
var nl, i;
nl = this.tags(f, "label");
for (i=0; i<nl.length; i++) {
if (nl[i].getAttribute("for") == n.id || nl[i].htmlFor == n.id)
this.addClass(nl[i], ic);
}
return null;
}
};
isEmail : function(s) {
return this.test(s, '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$');
},
isAbsUrl : function(s) {
return this.test(s, '^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+\\/?.*$');
},
isSize : function(s) {
return this.test(s, '^[0-9]+(%|in|cm|mm|em|ex|pt|pc|px)?$');
},
isId : function(s) {
return this.test(s, '^[A-Za-z_]([A-Za-z0-9_])*$');
},
isEmpty : function(s) {
var nl, i;
if (s.nodeName == 'SELECT' && s.selectedIndex < 1)
return true;
if (s.type == 'checkbox' && !s.checked)
return true;
if (s.type == 'radio') {
for (i=0, nl = s.form.elements; i<nl.length; i++) {
if (nl[i].type == "radio" && nl[i].name == s.name && nl[i].checked)
return false;
}
return true;
}
return new RegExp('^\\s*$').test(s.nodeType == 1 ? s.value : s);
},
isNumber : function(s, d) {
return !isNaN(s.nodeType == 1 ? s.value : s) && (!d || !this.test(s, '^-?[0-9]*\\.[0-9]*$'));
},
test : function(s, p) {
s = s.nodeType == 1 ? s.value : s;
return s == '' || new RegExp(p).test(s);
}
};
var AutoValidator = {
settings : {
id_cls : 'id',
int_cls : 'int',
url_cls : 'url',
number_cls : 'number',
email_cls : 'email',
size_cls : 'size',
required_cls : 'required',
invalid_cls : 'invalid',
min_cls : 'min',
max_cls : 'max'
},
init : function(s) {
var n;
for (n in s)
this.settings[n] = s[n];
},
validate : function(f) {
var i, nl, s = this.settings, c = 0;
nl = this.tags(f, 'label');
for (i=0; i<nl.length; i++)
this.removeClass(nl[i], s.invalid_cls);
c += this.validateElms(f, 'input');
c += this.validateElms(f, 'select');
c += this.validateElms(f, 'textarea');
return c == 3;
},
invalidate : function(n) {
this.mark(n.form, n);
},
reset : function(e) {
var t = ['label', 'input', 'select', 'textarea'];
var i, j, nl, s = this.settings;
if (e == null)
return;
for (i=0; i<t.length; i++) {
nl = this.tags(e.form ? e.form : e, t[i]);
for (j=0; j<nl.length; j++)
this.removeClass(nl[j], s.invalid_cls);
}
},
validateElms : function(f, e) {
var nl, i, n, s = this.settings, st = true, va = Validator, v;
nl = this.tags(f, e);
for (i=0; i<nl.length; i++) {
n = nl[i];
this.removeClass(n, s.invalid_cls);
if (this.hasClass(n, s.required_cls) && va.isEmpty(n))
st = this.mark(f, n);
if (this.hasClass(n, s.number_cls) && !va.isNumber(n))
st = this.mark(f, n);
if (this.hasClass(n, s.int_cls) && !va.isNumber(n, true))
st = this.mark(f, n);
if (this.hasClass(n, s.url_cls) && !va.isAbsUrl(n))
st = this.mark(f, n);
if (this.hasClass(n, s.email_cls) && !va.isEmail(n))
st = this.mark(f, n);
if (this.hasClass(n, s.size_cls) && !va.isSize(n))
st = this.mark(f, n);
if (this.hasClass(n, s.id_cls) && !va.isId(n))
st = this.mark(f, n);
if (this.hasClass(n, s.min_cls, true)) {
v = this.getNum(n, s.min_cls);
if (isNaN(v) || parseInt(n.value) < parseInt(v))
st = this.mark(f, n);
}
if (this.hasClass(n, s.max_cls, true)) {
v = this.getNum(n, s.max_cls);
if (isNaN(v) || parseInt(n.value) > parseInt(v))
st = this.mark(f, n);
}
}
return st;
},
hasClass : function(n, c, d) {
return new RegExp('\\b' + c + (d ? '[0-9]+' : '') + '\\b', 'g').test(n.className);
},
getNum : function(n, c) {
c = n.className.match(new RegExp('\\b' + c + '([0-9]+)\\b', 'g'))[0];
c = c.replace(/[^0-9]/g, '');
return c;
},
addClass : function(n, c, b) {
var o = this.removeClass(n, c);
n.className = b ? c + (o != '' ? (' ' + o) : '') : (o != '' ? (o + ' ') : '') + c;
},
removeClass : function(n, c) {
c = n.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)"), ' ');
return n.className = c != ' ' ? c : '';
},
tags : function(f, s) {
return f.getElementsByTagName(s);
},
mark : function(f, n) {
var s = this.settings;
this.addClass(n, s.invalid_cls);
this.markLabels(f, n, s.invalid_cls);
return false;
},
markLabels : function(f, n, ic) {
var nl, i;
nl = this.tags(f, "label");
for (i=0; i<nl.length; i++) {
if (nl[i].getAttribute("for") == n.id || nl[i].htmlFor == n.id)
this.addClass(nl[i], ic);
}
return null;
}
};
发表评论
-
sublime text 2使用心得汇总
2012-10-31 00:52 7843sublime介绍 突然之间,团队中更换了一 ... -
sublime text 2使用心得汇总
2012-10-30 22:00 0突然之间,团队中就出现了一个新的工具。她来得很突然, ... -
个人总结前端开发规范
2012-06-21 17:00 5190通用约定 文件与目录命名 一律小写, 必须是英文单 ... -
传说中的前端工程师技术图
2012-05-17 19:11 1123传说中的前端工程师技术图,真的很苦逼 -
dfasdfasdfasdf
2012-05-07 10:48 0<form action=""> ... -
dfasdfasdfasdf
2012-05-07 10:47 0<form action=""> ... -
test
2012-05-03 21:49 0<!DOCTYPE html PUBLIC &quo ... -
js中call和apply的用法
2012-04-06 16:57 1309说白了这两个方法可以像调用其他对象的方法一样调用函数。 先 ... -
javascript中this的用法
2012-04-06 16:30 1037this的用法分几种情况 1)如果调用this的functi ... -
jquery 中无法为window添加click事件的解决方法
2012-04-03 19:43 4472近期使用jquery编写插件的时候老遇到为window添加cl ... -
jquery 中无法为window添加click事件的解决方法
2012-04-03 19:39 2127近期写一个插件没注意又遇到使用$(widnow).click ... -
css3 控制文本超出后自动隐藏 属性
2012-03-31 16:54 1766首页,元素必须是定宽的,然后加入如下css代码: word- ... -
jQuery 脸部辨识
2012-02-29 14:00 1453jQuery 脸部辨识 jQuery的插件在照片上标识脸部并 ... -
【转】script标签中 text/javascript 和 application/javascript的区别
2012-02-03 11:56 2918js文件的mime类型为text/javascript,有时用 ... -
CSS英文、中文换行与不换行
2012-01-19 12:22 1575结构: 1.Transshipment Book ... -
jquery ajax多次请求数据时 不刷新问题解决
2012-01-19 11:33 3786jquery的ajax在频繁请求数据,或者重复请求数据 ... -
firebug 的console调试对象API
2012-01-19 10:13 1244Console API 当打开 firebug ( ... -
js判断页面是否在iframe或者frame里的一种偏锋写法
2011-12-30 19:03 2590整体思路: 判断页面最顶层的location地址,最后一 ... -
使用jquery判断鼠标滚动到页面底部
2011-12-26 12:56 4587$(function(){ $(window).scr ... -
分辨各种浏览器的hack
2011-08-17 15:58 859/* Opera */ html:first-child #o ...
相关推荐
本文实例为大家分享了bootstrapValidator.min.js表单验证的具体代码,供大家参考,具体内容如下 注意:下载后全选复制并粘贴到新建js文件名为bootstrapValidator.min.js下即可。 测试代码: <!DOCTYPE html> <...
bootstrapValidator表单验证插件,bootstrapValidator.css
bootstrap表单验证插件,css前边上传了,现在把bootstrapValidator.min.js也上传一下
bootstrap表单验证插件,简易配置参数,即可验证表单,非常好用,欢迎下载。
bootstrapvalidator 基于bootstrap的表单验证插件 基于bootstrap的表单验证插件
bootstrap-validator是一款简单实用的Bootstrap3表单验证jQuery插件。该表单验证插件使用HTML5的data属性来设置验证属性,可以完成所有常用的表单验证功能。
Mootools 表单验证插件 validator v4.0.zip
jquery validator的表单验证,注册的基本上的东西基本上都有了 感谢清风源 可学习 也可以学习
自已写的框架,用起来非常方便实用,有问题欢迎留言,开源的配置来太麻烦,学习成本比较高,我自己写的很简单实用!
import Validation from 'common/util/validation'; let validator = new Validation(); validator.addByValue('username',[ { strategy:'isEmpty', ...如果验证通过则返回undefined,否则是返回定义的文字信息
可以用此bootstrap-validator插件进行表单验证信息,给每个input 指定规则,验证无误才能提交按钮
jQuery form Validator Engine 表单输入判断验证插件,实时显示提示,当输入的数据不正确时,会给出提示,鼠标单击输入框时,也会显示出提示,比较人性化,不管是否输入,都会显示提示,这是一款来自jquery的输入...
Bootstrap Validator是为Bootstrap3设计的一款表单验证jQuery插件,非常适合基于Bootstrap框架的网站。 看作者的github,这款插件已经不再更新了,而推荐使用FormValidation,不过现在还是先介绍一下Bootstrap...
如图,这是使用Validator插件,所完成的功能,效果很强大,也很方便,这边推荐使用这种方式,最后介绍一下原始js验证写法。 首先,导入插件: <link href=<%=basePath %>bootstrap/css/bootstrap-...
bootstrapValidator 表单验证插件使用的汉化包,国际化汉化包
本文推荐一款twitter做的bootstrapValidator.js,本身bootstrap就是twitter做的,那么使用原配的validator也就更值得信赖。从百度上搜bootstrapValidator会出现很多款,但我只推荐这款: 一、一睹为快 为了简便的...