From 70aa5bba6c39370fed76c3a0ec24868ce2203efd Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 15 Mar 2019 17:04:56 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E4=BB=A3=E7=A0=81=EF=BC=9Alo?= =?UTF-8?q?ngbow.validate=E7=BB=84=E4=BB=B6=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #Comment Remote验证移到最后,优先检查不联网的rule --- .../wwwroot/lib/longbow/longbow.validate.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Bootstrap.Admin/wwwroot/lib/longbow/longbow.validate.js b/Bootstrap.Admin/wwwroot/lib/longbow/longbow.validate.js index efaa7c50..145a2d99 100644 --- a/Bootstrap.Admin/wwwroot/lib/longbow/longbow.validate.js +++ b/Bootstrap.Admin/wwwroot/lib/longbow/longbow.validate.js @@ -176,18 +176,28 @@ var $this = $(element); if ($this.is(':hidden')) return result; var methods = this.rules(element); - for (var rule in methods) { + var proxy = function(rule) { if ($.isFunction($.validator.methods[rule])) { result = $.validator.methods[rule].call(this.options, $this.val(), element, methods[rule]); if (!result) { $this.attr('data-original-title', this.defaultMessage(element, { method: rule, parameters: methods[rule] })); - break; + return result; } } else { console.log('没有匹配的方法 ' + rule); } + return true; } + var remote = null; + for (var rule in methods) { + if(rule !== 'remote') { + result = proxy.call(this, rule); + if(!result) return false; + } + else remote = rule; + } + if(remote !== null) result = proxy.call(this, remote); return result; };