/*! nice-validator 1.1.4 * (c) 2012-2018 jony zhang , mit licensed * https://github.com/niceue/nice-validator */ ! function(e) { "object" == typeof module && module.exports ? module.exports = e(require("jquery")) : "function" == typeof define && define.amd ? define(["jquery"], e) : e(jquery) }(function(e, t) { "use strict"; function i(t, n) { function s() { a.$el = e(t), a.$el.length ? a._init(a.$el[0], n) : w(t) && (z[t] = n) } var a = this; return a instanceof i ? void(i.pending ? e(window).on("validatorready", s) : s()) : new i(t, n) } function n(t) { function i() { var t = this.options; for (var i in t) i in k && (this[i] = t[i]); e.extend(this, { _valhook: function() { return "true" === this.element.contenteditable ? "text" : "val" }, getvalue: function() { var t = this.element; return "number" === t.type && t.validity && t.validity.badinput ? "nan" : e(t)[this._valhook()]() }, setvalue: function(t) { e(this.element)[this._valhook()](this.value = t) }, getrangemsg: function(e, t, i) { function n(e, t) { return o ? e > t : e >= t } if (t) { var s, a = this, r = a.messages[a._r] || "", l = t[0].split("~"), o = "false" === t[1], u = l[0], d = l[1], c = "rg", f = [""], g = p(e) && +e === +e; return 2 === l.length ? u && d ? (g && n(e, +u) && n(+d, e) && (s = !0), f = f.concat(l), c = o ? "gtlt" : "rg") : u && !d ? (g && n(e, +u) && (s = !0), f.push(u), c = o ? "gt" : "gte") : !u && d && (g && n(+d, e) && (s = !0), f.push(d), c = o ? "lt" : "lte") : (e === +u && (s = !0), f.push(u), c = "eq"), r && (i && r[c + i] && (c += i), f[0] = r[c]), s || a._rules && (a._rules[a._i].msg = a.rendermsg.apply(null, f)) } }, rendermsg: function() { var e = arguments, t = e[0], i = e.length; if (t) { for (; --i;) t = t.replace("{" + i + "}", e[i]); return t } } }) } function n(i, n, s) { this.key = i, this.validator = t, e.extend(this, s, n) } return i.prototype = t, n.prototype = new i, n } function s(e, t) { if (j(e)) { var i, n = t ? t === !0 ? this : t : s.prototype; for (i in e) g(i) && (n[i] = r(e[i])) } } function a(e, t) { if (j(e)) { var i, n = t ? t === !0 ? this : t : a.prototype; for (i in e) n[i] = e[i] } } function r(t) { switch (e.type(t)) { case "function": return t; case "array": var i = function() { return t[0].test(this.value) || t[1] || !1 }; return i.msg = t[1], i; case "regexp": return function() { return t.test(this.value) } } } function l(t) { var i, n, s; if (t && t.tagname) { switch (t.tagname) { case "input": case "select": case "textarea": case "button": case "fieldset": i = t.form || e(t).closest("." + k); break; case "form": i = t; break; default: i = e(t).closest("." + k) } for (n in z) if (e(i).is(n)) { s = z[n]; break } return e(i).data(p) || e(i)[p](s).data(p) } } function o(e, t) { var i = p(x(e, m + "-" + t)); if (i && (i = new function("return " + i)())) return r(i) } function u(e, t, i) { var n = t.msg, s = t._r; return j(n) && (n = n[s]), w(n) || (n = x(e, v + "-" + s) || x(e, v) || (i ? w(i) ? i : i[s] : "")), n } function d(e) { var t; return e && (t = d.exec(e)), t && t[0] } function c(e) { return "input" === e.tagname && "checkbox" === e.type || "radio" === e.type } function f(e) { return date.parse(e.replace(/\.|\-/g, "/")) } function g(e) { return /^\w+$/.test(e) } function m(e) { var t = "#" === e.charat(0); return e = e.replace(/([:.{(|)}\/\[\]])/g, "\\$1"), t ? e : '[name="' + e + '"]:first' } var h, p = "validator", v = "." + p, _ = ".rule", y = ".field", b = ".form", k = "nice-" + p, w = "msg-box", x = "aria-invalid", m = "data-rule", v = "data-msg", o = "data-tip", f = "data-ok", $ = "data-timely", e = "data-target", c = "data-display", a = "data-must", j = "novalidate", n = ":verifiable", t = /(&)?(!)?\b(\w+)(?:\[\s*(.*?\]?)\s*\]|\(\s*(.*?\)?)\s*\))?\s*(;|\|)?/g, s = /(\w+)(?:\[\s*(.*?\]?)\s*\]|\(\s*(.*?\)?)\s*\))?/, r = /(?:([^:;\(\[]*):)?(.*)/, q = /[^\x00-\xff]/g, d = /top|right|bottom|left/, i = /(?:(cors|jsonp):)?(?:(post|get):)?(.+)/i, h = /[<>'"`\\]|&#x?\d+[a-f]?;?|%3[a-f]/gim, l = e.noop, b = e.proxy, p = e.trim, u = e.isfunction, w = function(e) { return "string" == typeof e }, j = function(e) { return e && "[object object]" === object.prototype.tostring.call(e) }, q = document.documentmode || +(navigator.useragent.match(/msie (\d+)/) && regexp.$1), x = function(e, i, n) { return e && e.tagname ? n === t ? e.getattribute(i) : void(null === n ? e.removeattribute(i) : e.setattribute(i, "" + n)) : null }, z = {}, g = { debug: 0, theme: "default", ignore: "", focusinvalid: !0, focuscleanup: !1, stoponerror: !1, beforesubmit: null, valid: null, invalid: null, validation: null, formclass: "n-default", validclass: "n-valid", invalidclass: "n-invalid", bindclassto: null }, k = { timely: 1, display: null, target: null, ignoreblank: !1, showok: !0, datafilter: function(e) { if (w(e) || j(e) && ("error" in e || "ok" in e)) return e }, msgmaker: function(t) { var i; return i = '' + t.arrow, t.result ? e.each(t.result, function(e, n) { i += '' + t.icon + '' + n.msg + "" }) : i += t.icon + '' + t.msg + "", i += "" }, msgwrapper: "span", msgarrow: "", msgicon: '', msgclass: "n-right", msgstyle: "", msgshow: null, msghide: null }, y = {}; return e.fn.validator = function(t) { var n = this, s = arguments; return n.is(n) ? n : (n.is("form") || (n = this.find("form")), n.length || (n = this), n.each(function() { var n = e(this).data(p); if (n) if (w(t)) { if ("_" === t.charat(0)) return; n[t].apply(n, [].slice.call(s, 1)) } else t && (n._reset(!0), n._init(this, t)); else new i(this, t) }), this) }, e.fn.isvalid = function(e, i) { var n, s, a = l(this[0]), r = u(e); return !a || (r || i !== t || (i = e), a.checkonly = !!i, s = a.options, n = a._multivalidate(this.is(n) ? this : this.find(n), function(t) { t || !s.focusinvalid || a.checkonly || a.$el.find("[" + x + "]:first").focus(), r && (e.length ? e(t) : t && e()), a.checkonly = !1 }), r ? this : n) }, e.extend(e.expr.pseudos || e.expr[":"], { verifiable: function(e) { var t = e.nodename.tolowercase(); return ("input" === t && !{ submit: 1, button: 1, reset: 1, image: 1 }[e.type] || "select" === t || "textarea" === t || "true" === e.contenteditable) && !e.disabled }, filled: function(t) { return !!p(e(t).val()) } }), i.prototype = { _init: function(t, i) { var r, l, o, u = this; u(i) && (i = { valid: i }), i = u._opt = i || {}, o = x(t, "data-" + p + "-option"), o = u._dataopt = o && "{" === o.charat(0) ? new function("return " + o)() : {}, l = u._themeopt = y[i.theme || o.theme || g.theme], r = u.options = e.extend({}, g, k, l, u.options, i, o), u.rules = new s(r.rules, (!0)), u.messages = new a(r.messages, (!0)), u.field = n(u), u.elements = u.elements || {}, u.deferred = {}, u.errors = {}, u.fields = {}, u._initfields(r.fields), u.$el.data(p) || (u.$el.data(p, u).addclass(k + " " + r.formclass).on("form-submit-validate", function(e, t, i, n, s) { u.vetoed = s.veto = !u.isvalid, u.ajaxformoptions = n }).on("submit" + v + " validate" + v, b(u, "_submit")).on("reset" + v, b(u, "_reset")).on("showmsg" + v, b(u, "_showmsg")).on("hidemsg" + v, b(u, "_hidemsg")).on("focusin" + v + " click" + v, n, b(u, "_focusin")).on("focusout" + v + " validate" + v, n, b(u, "_focusout")).on("keyup" + v + " input" + v + " compositionstart compositionend", n, b(u, "_focusout")).on("click" + v, ":radio,:checkbox", "click", b(u, "_focusout")).on("change" + v, 'select,input[type="file"]', "change", b(u, "_focusout")), u._novalidate = x(t, j), x(t, j, j)), w(r.target) && u.$el.find(r.target).addclass("msg-container") }, _guessajax: function(t) { function i(t, i, n) { return !!(t && t[i] && e.map(t[i], function(e) { return ~e.namespace.indexof(n) ? 1 : null }).length) } var n = this; if (!(n.isajaxsubmit = !!n.options.valid)) { var s = (e._data || e.data)(t, "events"); n.isajaxsubmit = i(s, "valid", "form") || i(s, "submit", "form-plugin") } }, _initfields: function(e) { function t(e, t) { if (null === t || r) { var i = a.elements[e]; i && a._resetelement(i, !0), delete a.fields[e] } else a.fields[e] = new a.field(e, w(t) ? { rule: t } : t, a.fields[e]) } var i, n, s, a = this, r = null === e; if (r && (e = a.fields), j(e)) for (i in e) if (~i.indexof(",")) for (n = i.split(","), s = n.length; s--;) t(p(n[s]), e[i]); else t(i, e[i]); a.$el.find(n).each(function() { a._parse(this) }) }, _parse: function(e) { var t, i, n, s = this, a = e.name, r = x(e, m); return r && x(e, m, null), e.id && ("#" + e.id in s.fields || !a || null !== r && (t = s.fields[a]) && r !== t.rule && e.id !== t.key) && (a = "#" + e.id), a || (a = "#" + (e.id = "n" + string(math.random()).slice(-12))), t = s.getfield(a, !0), t.rule = r || t.rule, (i = x(e, c)) && (t.display = i), t.rule && ((null !== x(e, a) || /\b(?:match|checked)\b/.test(t.rule)) && (t.must = !0), /\brequired\b/.test(t.rule) && (t.required = !0), (n = x(e, $)) ? t.timely = +n : t.timely > 3 && x(e, $, t.timely), s._parserule(t), t.old = {}), w(t.target) && x(e, e, t.target), w(t.tip) && x(e, o, t.tip), s.fields[a] = t }, _parserule: function(i) { var n = r.exec(i.rule); n && (i._i = 0, n[1] && (i.display = n[1]), n[2] && (i._rules = [], n[2].replace(t, function() { var n = arguments; n[4] = n[4] || n[5], i._rules.push({ and: "&" === n[1], not: "!" === n[2], or: "|" === n[6], method: n[3], params: n[4] ? e.map(n[4].split(", "), p) : t }) }))) }, _multivalidate: function(i, n) { var s = this, a = s.options; return s.haserror = !1, a.ignore && (i = i.not(a.ignore)), i.each(function() { if (s._validate(this), s.haserror && a.stoponerror) return !1 }), n && (s.validating = !0, e.when.apply(null, e.map(s.deferred, function(e) { return e })).done(function() { n.call(s, !s.haserror), s.validating = !1 })), e.isemptyobject(s.deferred) ? !s.haserror : t }, _submit: function(i) { var n = this, s = n.options, a = i.target, r = "submit" === i.type && "form" === a.tagname && !i.isdefaultprevented(); i.preventdefault(), h && ~(h = !1) || n.submiting || "validate" === i.type && n.$el[0] !== a || u(s.beforesubmit) && s.beforesubmit.call(n, a) === !1 || (n.isajaxsubmit === t && n._guessajax(a), n._debug("log", "\n<<< event: " + i.type), n._reset(), n.submiting = !0, n._multivalidate(n.$el.find(n), function(t) { var i, l = t || 2 === s.debug ? "valid" : "invalid"; t || (s.focusinvalid && n.$el.find("[" + x + "]:first").focus(), i = e.map(n.errors, function(e) { return e })), n.submiting = !1, n.isvalid = t, u(s[l]) && s[l].call(n, a, i), n.$el.trigger(l + b, [a, i]), n._debug("log", ">>> " + l), t && (n.vetoed ? e(a).ajaxsubmit(n.ajaxformoptions) : r && !n.isajaxsubmit && document.createelement("form").submit.call(a)) })) }, _reset: function(e) { var t = this; t.errors = {}, e && (t.reseting = !0, t.$el.find(n).each(function() { t._resetelement(this) }), delete t.reseting) }, _resetelement: function(e, t) { this._setclass(e, null), this.hidemsg(e) }, _focusin: function(e) { var t, i, n = this, s = n.options, a = e.target; n.validating || "click" === e.type && document.activeelement === a || (s.focuscleanup && "true" === x(a, x) && (n._setclass(a, null), n.hidemsg(a)), i = x(a, o), i ? n.showmsg(a, { type: "tip", msg: i }) : (x(a, m) && n._parse(a), (t = x(a, $)) && (8 !== t && 9 !== t || n._focusout(e)))) }, _focusout: function(t) { var i, n, s, a, r, l, o, u, d, f = this, g = f.options, m = t.target, h = t.type, p = "focusin" === h, v = "validate" === h, _ = 0; if ("compositionstart" === h && (f.pausevalidate = !0), "compositionend" === h && (f.pausevalidate = !1), !f.pausevalidate && (n = m.name && c(m) ? f.$el.find('input[name="' + m.name + '"]').get(0) : m, (s = f.getfield(n)) && s.rule)) { if (i = s._e, s._e = h, d = s.timely, !v) { if (!d || c(m) && "click" !== h) return; if (r = s.getvalue(), s.ignoreblank && !r && !p) return void f.hidemsg(m); if ("focusout" === h) { if ("change" === i) return; if (2 === d || 8 === d) { if (a = s.old, !r || !a) return; s.isvalid && !a.showok ? f.hidemsg(m) : f._makemsg(m, s, a) } } else { if (d < 2 && !t.data) return; if (l = +new date, l - (m._ts || 0) < 100) return; if (m._ts = l, "keyup" === h) { if ("input" === i) return; if (o = t.keycode, u = { 8: 1, 9: 1, 16: 1, 32: 1, 46: 1 }, 9 === o && !r) return; if (o < 48 && !u[o]) return } p || (_ = d < 100 ? "click" === h || "select" === m.tagname ? 0 : 400 : d) } } g.ignore && e(m).is(g.ignore) || (cleartimeout(s._t), _ ? s._t = settimeout(function() { f._validate(m, s) }, _) : (v && (s.old = {}), f._validate(m, s))) } }, _setclass: function(t, i) { var n = e(t), s = this.options; s.bindclassto && (n = n.closest(s.bindclassto)), n.removeclass(s.invalidclass + " " + s.validclass), null !== i && n.addclass(i ? s.validclass : s.invalidclass) }, _showmsg: function(e, t, i) { var n = this, s = e.target; n.$el.is(s) ? j(t) ? n.showmsg(t) : "tip" === t && n.$el.find(n + "[" + o + "]", s).each(function() { n.showmsg(this, { type: t, msg: i }) }) : n.showmsg(s, { type: t, msg: i }) }, _hidemsg: function(t) { var i = e(t.target); i.is(n) && this.hidemsg(i) }, _validatedfield: function(t, i, n) { var s = this, a = s.options, r = i.isvalid = n.isvalid = !!n.isvalid, l = r ? "valid" : "invalid"; n.key = i.key, n.rulename = i._r, n.id = t.id, n.value = i.value, s.elements[i.key] = n.element = t, s.isvalid = s.$el[0].isvalid = r ? s.isformvalid() : r, r ? n.type = "ok" : (s.submiting && (s.errors[i.key] = n.msg), s.haserror = !0), i.old = n, u(i[l]) && i[l].call(s, t, n), u(a.validation) && a.validation.call(s, t, n), e(t).attr(x, !r || null).trigger(l + y, [n, s]), s.$el.triggerhandler("validation", [n, s]), s.checkonly || (s._setclass(t, n.skip || "tip" === n.type ? null : r), s._makemsg.apply(s, arguments)) }, _makemsg: function(t, i, n) { i.msgmaker && (n = e.extend({}, n), "focusin" === i._e && (n.type = "tip"), this[n.showok || n.msg || "tip" === n.type ? "showmsg" : "hidemsg"](t, n, i)) }, _validatedrule: function(i, n, s, a) { n = n || c.getfield(i), a = a || {}; var r, l, o, d, c = this, f = n._r, g = n.timely, m = 9 === g || 8 === g, h = !1; if (null === s) return c._validatedfield(i, n, { isvalid: !0, skip: !0 }), void(n._i = 0); if (s === t ? o = !0 : s === !0 || "" === s ? h = !0 : w(s) ? r = s : j(s) ? s.error ? r = s.error : (r = s.ok, h = !0) : h = !!s, l = n._rules[n._i], l.not && (r = t, h = "required" === f || !h), l.or) if (h) for (; n._i < n._rules.length && n._rules[n._i].or;) n._i++; else o = !0; else l.and && (n.isvalid || (o = !0)); o ? h = !0 : (h && n.showok !== !1 && (d = x(i, f), r = null === d ? w(n.ok) ? n.ok : r : d, !w(r) && w(n.showok) && (r = n.showok), w(r) && (a.showok = h)), h && !m || (r = (u(i, n, r || l.msg || c.messages[f]) || c.messages.fallback).replace(/\{0\|?([^\}]*)\}/, function(e, t) { return c._getdisplay(i, n.display) || t || c.messages[0] })), h || (n.isvalid = h), a.msg = r, e(i).trigger((h ? "valid" : "invalid") + _, [f, r])), !m || o && !l.and || (h || n._m || (n._m = r), n._v = n._v || [], n._v.push({ type: h ? o ? "tip" : "ok" : "error", msg: r || l.msg })), c._debug("log", " " + n._i + ": " + f + " => " + (h || r)), (h || m) && n._i < n._rules.length - 1 ? (n._i++, c._checkrule(i, n)) : (n._i = 0, m ? (a.isvalid = n.isvalid, a.result = n._v, a.msg = n._m || "", n.value || "focusin" !== n._e || (a.type = "tip")) : a.isvalid = h, c._validatedfield(i, n, a), delete n._m, delete n._v) }, _checkrule: function(i, n) { var s, a, r, l = this, u = n.key, d = n._rules[n._i], c = d.method, f = d.params; l.submiting && l.deferred[u] || (r = n.old, n._r = c, r && !n.must && !d.must && d.result !== t && r.rulename === c && r.id === i.id && n.value && r.value === n.value ? s = d.result : (a = o(i, c) || l.rules[c] || l, s = a.call(n, i, f, n), a.msg && (d.msg = a.msg)), j(s) && u(s.then) ? (l.deferred[u] = s, n.isvalid = t, !l.checkonly && l.showmsg(i, { type: "loading", msg: l.messages.loading }, n), s.then(function(s, a, r) { var o, u = p(r.responsetext), c = n.datafilter; /jsonp?/.test(this.datatype) ? u = s : "{" === u.charat(0) && (u = e.parsejson(u)), o = c.call(this, u, n), o === t && (o = c.call(this, u.data, n)), d.data = this.data, d.result = n.old ? o : t, l._validatedrule(i, n, o) }, function(e, t) { l._validatedrule(i, n, l.messages[t] || t) }).always(function() { delete l.deferred[u] })) : l._validatedrule(i, n, s)) }, _validate: function(e, t) { var i = this; if (!e.disabled && null === x(e, j) && (t = t || i.getfield(e), t && (t._rules || i._parse(e), t._rules))) return i._debug("info", t.key), t.isvalid = !0, t.element = e, t.value = t.getvalue(), t.required || t.must || t.value || c(e) ? (i._checkrule(e, t), t.isvalid) : (i._validatedfield(e, t, { isvalid: !0 }), !0) }, _debug: function(e, t) { window.console && this.options.debug && console[e](t) }, test: function(e, i) { var n, s, a, r, l = this, o = s.exec(i); return o && (a = o[1], a in l.rules && (r = o[2] || o[3], r = r ? r.split(", ") : t, s = l.getfield(e, !0), s._r = a, s.value = s.getvalue(), n = l.rules[a].call(s, e, r))), n === !0 || n === t || null === n }, _getdisplay: function(e, t) { return w(t) ? t : u(t) ? t.call(this, e) : "" }, _getmsgopt: function(t, i) { var n = i ? i : this.options; return e.extend({ type: "error", pos: d(n.msgclass), target: n.target, wrapper: n.msgwrapper, style: n.msgstyle, cls: n.msgclass, arrow: n.msgarrow, icon: n.msgicon }, w(t) ? { msg: t } : t) }, _getmsgdom: function(i, n) { var s, a, r, l, o = e(i); if (o.is(n) ? (r = n.target || x(i, e), r && (r = u(r) ? r.call(this, i) : "#" === r.charat(0) ? e(r) : this.$el.find(r), r.length && (r.is(n) ? (o = r, i = r.get(0)) : r.hasclass(w) ? s = r : l = r)), s || (a = c(i) && i.name || !i.id ? i.name : i.id, s = (l || this.$el).find(n.wrapper + "." + w + '[for="' + a + '"]'))) : s = o, !n.hide && !s.length) if (s = e("<" + n.wrapper + ">").attr({ "class": w + (n.cls ? " " + n.cls : ""), style: n.style || t, "for": a }), l) s.appendto(l); else if (c(i)) { var u = o.parent(); s.appendto(u.is("label") ? u.parent() : u) } else s[n.pos && "right" !== n.pos ? "insertbefore" : "insertafter"](o); return s }, showmsg: function(t, i, n) { if (t) { var s, a, r, l, o = this, u = o.options; if (j(t) && !t.jquery && !i) return void e.each(t, function(e, t) { var i = o.elements[e] || o.$el.find(m(e))[0]; o.showmsg(i, t) }); e(t).is(n) && (n = n || o.getfield(t)), (a = (n || u).msgmaker) && (i = o._getmsgopt(i, n), t = (t.name && c(t) ? o.$el.find('input[name="' + t.name + '"]') : e(t)).get(0), i.msg || "error" === i.type || (r = x(t, "data-" + i.type), null !== r && (i.msg = r)), w(i.msg) && (l = o._getmsgdom(t, i), !d.test(l[0].classname) && l.addclass(i.cls), 6 === q && "bottom" === i.pos && (l[0].style.margintop = e(t).outerheight() + "px"), l.html(a.call(o, i))[0].style.display = "", u(s = n && n.msgshow || u.msgshow) && s.call(o, l, i.type))) } }, hidemsg: function(t, i, n) { var s, a, r = this, l = r.options; t = e(t).get(0), e(t).is(n) && (n = n || r.getfield(t), n && (n.isvalid || r.reseting) && x(t, x, null)), i = r._getmsgopt(i, n), i.hide = !0, a = r._getmsgdom(t, i), a.length && (u(s = n && n.msghide || l.msghide) ? s.call(r, a, i.type) : (a[0].style.display = "none", a[0].innerhtml = "")) }, getfield: function(e, i) { var n, s, a = this; if (w(e)) n = e, e = t; else { if (x(e, m)) return a._parse(e); n = e.id && "#" + e.id in a.fields || !e.name ? "#" + e.id : e.name } return ((s = a.fields[n]) || i && (s = new a.field(n))) && (s.element = e), s }, setfield: function(e, t) { var i = {}; e && (w(e) ? i[e] = t : i = e, this._initfields(i)) }, isformvalid: function() { var e, t, i = this.fields; for (e in i) if (t = i[e], t._rules && (t.required || t.must || t.value) && !t.isvalid) return !1; return !0 }, holdsubmit: function(e) { this.submiting = e === t || e }, cleanup: function() { this._reset(1) }, destroy: function() { this._reset(1), this.$el.off(v).removedata(p), x(this.$el[0], j, this._novalidate) } }, e(window).on("beforeunload", function() { this.focus() }), e(document).on("click", ":submit", function() { var e, t = this; t.form && (e = t.getattributenode("formnovalidate"), (e && null !== e.nodevalue || null !== x(t, j)) && (h = !0)) }).on("focusin submit validate", "form,." + k, function(t) { if (null === x(this, j)) { var i, n = e(this);!n.data(p) && (i = l(this)) && (e.isemptyobject(i.fields) ? (x(this, j, j), n.off(v).removedata(p)) : "focusin" === t.type ? i._focusin(t) : i._submit(t)) } }), new a({ fallback: "this field is not valid.", loading: "validating..." }), new s({ required: function(t, i) { var n = this, s = p(n.value), a = !0; if (i) if (1 === i.length) { if (g(i[0])) { if (n.rules[i[0]] && !s && !n.test(t, i[0])) return null } else if (!s && !e(i[0], n.$el).length) return null } else if ("not" === i[0]) e.each(i.slice(1), function() { return a = s !== p(this) }); else if ("from" === i[0]) { var r, l = n.$el.find(i[1]), o = "_validated_"; return a = l.filter(function() { var e = n.getfield(this); return e && !!p(e.getvalue()) }).length >= (i[2] || 1), a ? s || (r = null) : r = u(l[0], n) || !1, e(t).data(o) || l.data(o, 1).each(function() { t !== this && n._validate(this) }).removedata(o), r } return a && !!s }, integer: function(e, t) { var i, n = "0|", s = "[1-9]\\d*", a = t ? t[0] : "*"; switch (a) { case "+": i = s; break; case "-": i = "-" + s; break; case "+0": i = n + s; break; case "-0": i = n + "-" + s; break; default: i = n + "-?" + s } return i = "^(?:" + i + ")$", new regexp(i).test(this.value) || this.messages.integer && this.messages.integer[a] }, match: function(t, i) { if (i) { var n, s, a, r, l, o, u, d = this, c = !0, g = "eq"; if (1 === i.length ? a = i[0] : (g = i[0], a = i[1]), l = m(a), o = d.$el.find(l)[0]) { if (u = d.getfield(o), n = d.value, s = u.getvalue(), d._match || (d.$el.on("valid" + y + v, l, function() { e(t).trigger("validate") }), d._match = u._match = 1), !d.required && "" === n && "" === s) return null; if (r = i[2], r && (/^date(time)?$/i.test(r) ? (n = f(n), s = f(s)) : "time" === r && (n = +n.replace(/:/g, ""), s = +s.replace(/:/g, ""))), "eq" !== g && !isnan(+n) && isnan(+s)) return !0; switch (g) { case "lt": c = +n < +s; break; case "lte": c = +n <= +s; break; case "gte": c = +n >= +s; break; case "gt": c = +n > +s; break; case "neq": c = n !== s; break; default: c = n === s } return c || j(d.messages.match) && d.messages.match[g].replace("{1}", d._getdisplay(o, u.display || a)) } } }, range: function(e, t) { return this.getrangemsg(this.value, t) }, checked: function(e, t) { if (c(e)) { var i, n, s = this; return e.name ? n = s.$el.find('input[name="' + e.name + '"]').filter(function() { var e = this; return !i && c(e) && (i = e), !e.disabled && e.checked }).length : (i = e, n = i.checked), t ? s.getrangemsg(n, t) : !!n || u(i, s, "") || s.messages.required || !1 } }, length: function(e, t) { var i = this.value, n = ("true" === t[1] ? i.replace(q, "xx") : i).length; return this.getrangemsg(n, t, t[1] ? "_2" : "") }, remote: function(t, i) { if (i) { var n, s = this, a = i.exec(i[0]), r = s._rules[s._i], l = {}, o = "", u = a[3], d = a[2] || "post", c = (a[1] || "").tolowercase(); return r.must = !0, l[t.name] = s.value, i[1] && e.map(i.slice(1), function(e) { var t, i;~e.indexof("=") ? o += "&" + e : (t = e.split(":"), e = p(t[0]), i = p(t[1]) || e, l[e] = s.$el.find(m(i)).val()) }), l = e.param(l) + o, !s.must && r.data && r.data === l ? r.result : ("cors" !== c && /^https?:/.test(u) && !~u.indexof(location.host) && (n = "jsonp"), e.ajax({ url: u, type: d, data: l, datatype: n })) } }, filter: function(e, t) { var i = this.value, n = i.replace(t ? new regexp("[" + t[0] + "]", "gm") : h, ""); n !== i && this.setvalue(n) } }), i.config = function(t, i) { function n(e, t) { "rules" === e ? new s(t) : "messages" === e ? new a(t) : e in k ? k[e] = t : g[e] = t } j(t) ? e.each(t, n) : w(t) && n(t, i) }, i.settheme = function(t, i) { j(t) ? e.extend(!0, y, t) : w(t) && j(i) && (y[t] = e.extend(y[t], i)) }, i.load = function(t) { if (t) { var n, s, a, r = document, l = {}, o = r.scripts[0]; t.replace(/([^?=&]+)=([^&#]*)/g, function(e, t, i) { l[t] = i }), n = l.dir || i.dir, i.css || "" === l.css || (s = r.createelement("link"), s.rel = "stylesheet", s.href = i.css = n + "jquery.validator.css", o.parentnode.insertbefore(s, o)), !i.local && ~t.indexof("local") && "" !== l.local && (i.local = (l.local || r.documentelement.lang || "en").replace("_", "-"), i.pending = 1, s = r.createelement("script"), s.src = n + "local/" + i.local + ".js", a = "onload" in s ? "onload" : "onreadystatechange", s[a] = function() { s.readystate && !/loaded|complete/.test(s.readystate) || (s = s[a] = null, delete i.pending, e(window).triggerhandler("validatorready")) }, o.parentnode.insertbefore(s, o)) } }, function() { for (var e, t, n = document.scripts, s = n.length, a = /(.*validator(?:\.min)?.js)(\?.*(?:local|css|dir)(?:=[\w\-]*)?)?/; s-- && !t;) e = n[s], t = (e.hasattribute ? e.src : e.getattribute("src", 4) || "").match(a); t && (i.dir = t[1].split("/").slice(0, -1).join("/") + "/", i.load(t[2])) }(), e[p] = i }); /********************************* * themes, rules, and i18n support * locale: chinese; 中文 *********************************/ (function(factory) { typeof module === "object" && module.exports ? module.exports = factory(require("jquery")) : typeof define === 'function' && define.amd ? define(['jquery'], factory) : factory(jquery); }(function($) { /* global configuration */ $.validator.config({ //stoponerror: true, //focuscleanup: true, //theme: 'yellow_right', //timely: 2, // custom rules rules: { digits: [/^\d+$/, "请填写数字"], letters: [/^[a-z]+$/i, "请填写字母"], date: [/^\d{4}-\d{2}-\d{2}$/, "请填写有效的日期,格式:yyyy-mm-dd"], time: [/^([01]\d|2[0-3])(:[0-5]\d){1,2}$/, "请填写有效的时间,00:00到23:59之间"], email: [/^[\w\+\-]+(\.[\w\+\-]+)*@[a-z\d\-]+(\.[a-z\d\-]+)*\.([a-z]{2,4})$/i, "请填写有效的邮箱"], url: [/^(https?|s?ftp):\/\/\s+$/i, "请填写有效的网址"], qq: [/^[1-9]\d{4,}$/, "请填写有效的qq号"], idcard: [/^\d{6}(19|2\d)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|x)?$/, "请填写正确的身份证号码"], tel: [/^(?:(?:0\d{2,3}[\- ]?[1-9]\d{6,7})|(?:[48]00[\- ]?[1-9]\d{6}))$/, "请填写有效的电话号码"], mobile: [/^1[3-9]\d{9}$/, "请填写有效的手机号"], zipcode: [/^\d{6}$/, "请检查邮政编码格式"], chinese: [/^[\u0391-\uffe5]+$/, "请填写中文字符"], username: [/^\w{3,12}$/, "请填写3-12位数字、字母、下划线"], password: [/^[\s]{6,16}$/, "请填写6-16位字符,不能包含空格"], accept: function(element, params) { if (!params) return true; var ext = params[0], value = $(element).val(); return (ext === '*') || (new regexp(".(?:" + ext + ")$", "i")).test(value) || this.rendermsg("只接受{1}后缀的文件", ext.replace(/\|/g, ',')); } }, // default error messages messages: { 0: "此处", fallback: "{0}格式不正确", loading: "正在验证...", error: "网络异常", timeout: "请求超时", required: "{0}can not be empty", remote: "{0}已被使用", integer: { '*': "请填写整数", '+': "请填写正整数", '+0': "请填写正整数或0", '-': "请填写负整数", '-0': "请填写负整数或0" }, match: { eq: "{0}与{1}不一致", neq: "{0}与{1}不能相同", lt: "{0}必须小于{1}", gt: "{0}必须大于{1}", lte: "{0}不能大于{1}", gte: "{0}不能小于{1}" }, range: { rg: "请填写{1}到{2}的数", gte: "请填写不小于{1}的数", lte: "请填写最大{1}的数", gtlt: "请填写{1}到{2}之间的数", gt: "请填写大于{1}的数", lt: "请填写小于{1}的数" }, checked: { eq: "请选择{1}项", rg: "请选择{1}到{2}项", gte: "请至少选择{1}项", lte: "请最多选择{1}项" }, length: { eq: "请填写{1}个字符", rg: "请填写{1}到{2}个字符", gte: "请至少填写{1}个字符", lte: "请最多填写{1}个字符", eq_2: "", rg_2: "", gte_2: "", lte_2: "" } } }); /* themes */ var tpl_arrow = ''; $.validator.settheme({ 'simple_right': { formclass: 'n-simple', msgclass: 'n-right' }, 'simple_bottom': { formclass: 'n-simple', msgclass: 'n-bottom' }, 'yellow_top': { formclass: 'n-yellow', msgclass: 'n-top', msgarrow: tpl_arrow }, 'yellow_right': { formclass: 'n-yellow', msgclass: 'n-right', msgarrow: tpl_arrow }, 'yellow_right_effect': { formclass: 'n-yellow', msgclass: 'n-right', msgarrow: tpl_arrow, msgshow: function($msgbox, type) { var $el = $msgbox.children(); if ($el.is(':animated')) return; if (type === 'error') { $el.css({ left: '20px', opacity: 0 }) .delay(100).show().stop() .animate({ left: '-4px', opacity: 1 }, 150) .animate({ left: '3px' }, 80) .animate({ left: 0 }, 80); } else { $el.css({ left: 0, opacity: 1 }).fadein(200); } }, msghide: function($msgbox, type) { var $el = $msgbox.children(); $el.stop().delay(100).show() .animate({ left: '20px', opacity: 0 }, 300, function() { $msgbox.hide(); }); } } }); }));