Skip to content

Commit 81ba504

Browse files
committed
修正单词拼写错误;优化调试信息输出
1 parent 7d35ef1 commit 81ba504

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

jquery-validator-1.3.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
@Version: 1.3.0 beta
44
@Author: Ready
55
@Date: 2015-02-25
6-
@Blog: http://www.365mini.com
6+
@Documentation: http://www.365mini.com/page/jquery-validator-quickstart.htm
77
@Copyright: CodePlayer( Ready )
88
99
@Licence: https://www.apache.org/licenses/LICENSE-2.0.html
1010
*/
1111
!function ($, global) {
1212
var console = global && global.console;
1313
if(typeof jQuery === "undefined" || $ !== jQuery){
14-
console && console.log("jQuery must be initialied before loading the Validator.");
14+
console && console.log("jQuery must be initialized before loading the Validator.");
1515
return;
1616
};
1717
var V = function(method){
@@ -262,7 +262,7 @@
262262
}
263263
context.label = label;
264264
}
265-
return context.birthday = date;
265+
return date;
266266
}
267267
},
268268
// 校验器
@@ -509,15 +509,16 @@
509509
},
510510
// 执行单个校验
511511
validate: function(value, rule, event){
512-
var me = this, context;
512+
var me = this, context, is$;
513513
if( typeof rule === "string" ){
514514
rule = me.getRule(rule);
515515
if( !rule ) throw "validate rule not found:" + rule;
516516
}
517517
context = V.context = { origin: rule };
518518
rule = context.rule = me.clipRule( rule );
519-
V.debug && log( "current validate context:", context );
520-
if( value instanceof $ ){
519+
is$ = value instanceof $;
520+
V.debug && log( "current validate context [" + (is$ ? value.prop("name") : value) + "]:" , context );
521+
if( is$ ){
521522
if(!value.length && !this.strict) return me.afterHandler(true, context); // 非严格模式,直接跳过校验
522523
context.$dom = value;
523524
value = me.getValue(value, context);
@@ -544,7 +545,7 @@
544545
if(value == null) context.value = value = ""; // 确保校验器接收到的不会为null或undefined
545546
// 如果设置了非空验证
546547
if( rule.required != null ){
547-
context.validator = "required";
548+
context.validator = "required", context.expression = rule.required;
548549
if( me.validator.required.call(me, value, rule.required, context) === false){
549550
return me.afterHandler(false, context);
550551
}
@@ -553,7 +554,7 @@
553554
}
554555
// 如果设置了格式验证
555556
if( rule.format ){
556-
context.validator = "format";
557+
context.validator = "format", context.expression = rule.format;
557558
value = me.validator.format.call(me, value, rule.format, context);
558559
if( value === false ) return me.afterHandler(false, context);
559560
if( context._stop ) return me.afterHandler(true, context);
@@ -563,7 +564,7 @@
563564
for(var i in rule){
564565
var validator = me.validator[i];
565566
if( validator ){
566-
context.validator = i;
567+
context.validator = i, context.expression = rules[i];
567568
if( validator.call(me, value, rule[i], context) === false ){
568569
return me.afterHandler(false, context);
569570
}
@@ -828,7 +829,7 @@
828829
"username": {
829830
pre: "trimAll,lower,flush",
830831
text: /^[a-z][a-z0-9_]{5,15}$/i,
831-
message: "{label}必须是英文、数字和下划线组成的6~16位字符,并且必须以字母开头!"
832+
message: "{label}必须是英文字母、数字和下划线组成的6~16位字符,并且必须以字母开头!"
832833
},
833834
"password": {
834835
length: "[6,16]"

0 commit comments

Comments
 (0)