(function(b) {
var a = {
init : function(c) {
var d = this;
if (!d.data("jqv") || d.data("jqv") == null) {
c = a._saveOptions(d, c);
b(".formError").on("click", function() {
b(this).fadeOut(150, function() {
b(this).parent(".formErrorOuter").remove();
b(this).remove()
})
})
}
return this
},
attach : function(e) {
if (!b(this).is("form")) {
alert("Sorry, jqv.attach() only applies to a form");
return this
}
var d = this;
var c;
if (e) {
c = a._saveOptions(d, e)
} else {
c = d.data("jqv")
}
c.validateAttribute = (d.find("[data-validation-engine*=validate]").length) ? "data-validation-engine"
: "class";
if (c.binded) {
d.find("[" + c.validateAttribute + "*=validate]").not(
"[type=checkbox]").not("[type=radio]").not(
".datepicker").bind(c.validationEventTrigger,
a._onFieldEvent);
d.find(
"[" + c.validateAttribute
+ "*=validate][type=checkbox],["
+ c.validateAttribute
+ "*=validate][type=radio]").bind("click",
a._onFieldEvent);
d.find(
"[" + c.validateAttribute
+ "*=validate][class*=datepicker]").bind(
c.validationEventTrigger, {
delay : 300
}, a._onFieldEvent)
}
if (c.autoPositionUpdate) {
b(window).bind("resize", {
noAnimation : true,
formElem : d
}, a.updatePromptsPosition)
}
d.bind("submit", a._onSubmitEvent);
return this
},
detach : function() {
if (!b(this).is("form")) {
alert("Sorry, jqv.detach() only applies to a form");
return this
}
var d = this;
var c = d.data("jqv");
d.find("[" + c.validateAttribute + "*=validate]").not(
"[type=checkbox]").unbind(c.validationEventTrigger,
a._onFieldEvent);
d
.find(
"["
+ c.validateAttribute
+ "*=validate][type=checkbox],[class*=validate][type=radio]")
.unbind("click", a._onFieldEvent);
d.unbind("submit", a.onAjaxFormComplete);
d.find("[" + c.validateAttribute + "*=validate]").not(
"[type=checkbox]").die(c.validationEventTrigger,
a._onFieldEvent);
d.find("[" + c.validateAttribute + "*=validate][type=checkbox]")
.die("click", a._onFieldEvent);
d.die("submit", a.onAjaxFormComplete);
d.removeData("jqv");
if (c.autoPositionUpdate) {
b(window).unbind("resize", a.updatePromptsPosition)
}
return this
},
validate : function() {
if (b(this).is("form")) {
return a._validateFields(this)
} else {
var e = b(this).closest("form");
var c = e.data("jqv");
var d = a._validateField(b(this), c);
if (c.onSuccess && c.InvalidFields.length == 0) {
c.onSuccess()
} else {
if (c.onFailure && c.InvalidFields.length > 0) {
c.onFailure()
}
}
return d
}
},
updatePromptsPosition : function(f) {
if (f && this == window) {
var e = f.data.formElem;
var c = f.data.noAnimation
} else {
var e = b(this.closest("form"))
}
var d = e.data("jqv");
e.find("[" + d.validateAttribute + "*=validate]").not(":disabled")
.each(function() {
var i = b(this);
var g = a._getPrompt(i);
var h = b(g).find(".formErrorContent").html();
if (g) {
a._updatePrompt(i, b(g), h, undefined, false, d, c)
}
});
return this
},
showPrompt : function(d, f, h, e) {
var g = this.closest("form");
var c = g.data("jqv");
if (!c) {
c = a._saveOptions(this, c)
}
if (h) {
c.promptPosition = h
}
c.showArrow = e == true;
a._showPrompt(this, d, f, false, c);
return this
},
hide : function() {
var f = b(this).closest("form");
var d = f.data("jqv");
var e = (d && d.fadeDuration) ? d.fadeDuration : 0.3;
var c;
if (b(this).is("form")) {
c = "parentForm" + a._getClassName(b(this).attr("id"))
} else {
c = a._getClassName(b(this).attr("id")) + "formError"
}
b("." + c).fadeTo(e, 0.3, function() {
b(this).parent(".formErrorOuter").remove();
b(this).remove()
});
return this
},
hideAll : function() {
var d = this;
var c = d.data("jqv");
var e = c ? c.fadeDuration : 0.3;
b(".formError").fadeTo(e, 0.3, function() {
b(this).parent(".formErrorOuter").remove();
b(this).remove()
});
return this
},
_onFieldEvent : function(e) {
var f = b(this);
var d = f.closest("form");
var c = d.data("jqv");
c.eventTrigger = "field";
window.setTimeout(function() {
a._validateField(f, c);
if (c.InvalidFields.length == 0 && c.onSuccess) {
c.onSuccess()
} else {
if (c.InvalidFields.length > 0 && c.onFailure) {
c.onFailure()
}
}
}, (e.data) ? e.data.delay : 0)
},
_onSubmitEvent : function() {
var e = b(this);
var c = e.data("jqv");
c.eventTrigger = "submit";
var d = a._validateFields(e);
if (d && c.ajaxFormValidation) {
a._validateFormWithAjax(e, c);
return false
}
if (c.onValidationComplete) {
return !!c.onValidationComplete(e, d)
}
return d
},
_checkAjaxStatus : function(d) {
var c = true;
b.each(d.ajaxValidCache, function(e, f) {
if (!f) {
c = false;
return false
}
});
return c
},
_checkAjaxFieldStatus : function(c, d) {
return d.ajaxValidCache[c] == true
},
_validateFields : function(e) {
var m = e.data("jqv");
var f = false;
e.trigger("jqv.form.validating");
var n = null;
e.find("[" + m.validateAttribute + "*=validate]").not(":disabled")
.each(
function() {
var p = b(this);
var o = [];
if (b.inArray(p.attr("name"), o) < 0) {
f |= a._validateField(p, m);
if (f && n == null) {
if (p.is(":hidden") && m.prettySelect) {
n = p = e.find("#" + m.usePrefix
+ p.attr("id")
+ m.useSuffix)
} else {
n = p
}
}
if (m.doNotShowAllErrosOnSubmit) {
return false
}
o.push(p.attr("name"));
if (m.showOneMessage == true && f) {
return false
}
}
});
e.trigger("jqv.form.result", [ f ]);
if (f) {
if (m.scroll) {
var l = n.offset().top;
var h = n.offset().left;
var j = m.promptPosition;
if (typeof (j) == "string" && j.indexOf(":") != -1) {
j = j.substring(0, j.indexOf(":"))
}
if (j != "bottomRight" && j != "bottomLeft") {
var i = a._getPrompt(n);
l = i.offset().top
}
if (m.isOverflown) {
var c = b(m.overflownDIV);
if (!c.length) {
return false
}
var d = c.scrollTop();
var g = -parseInt(c.offset().top);
l += d + g - 5;
var k = b(m.overflownDIV + ":not(:animated)");
k.animate({
scrollTop : l
}, 1100, function() {
if (m.focusFirstField) {
n.focus()
}
})
} else {
b("html:not(:animated),body:not(:animated)").animate({
scrollTop : l,
scrollLeft : h
}, 1100, function() {
if (m.focusFirstField) {
n.focus()
}
})
}
} else {
if (m.focusFirstField) {
n.focus()
}
}
return false
}
return true
},
_validateFormWithAjax : function(g, e) {
var h = g.serialize();
var f = (e.ajaxmethod) ? e.ajaxmethod : "GET";
var d = (e.ajaxFormValidationURL) ? e.ajaxFormValidationURL : g
.attr("action");
var c = (e.dataType) ? e.dataType : "json";
b.ajax({
type : f,
url : d,
cache : false,
dataType : c,
data : h,
form : g,
methods : a,
options : e,
beforeSend : function() {
return e.onBeforeAjaxFormValidation(g, e)
},
error : function(i, j) {
a._ajaxError(i, j)
},
success : function(n) {
if ((c == "json") && (n !== true)) {
var l = false;
for ( var m = 0; m < n.length; m++) {
var o = n[m];
var q = o[0];
var k = b(b("#" + q)[0]);
if (k.length == 1) {
var p = o[2];
if (o[1] == true) {
if (p == "" || !p) {
a._closePrompt(k)
} else {
if (e.allrules[p]) {
var j = e.allrules[p].alertTextOk;
if (j) {
p = j
}
}
a._showPrompt(k, p, "pass", false, e,
true)
}
} else {
l |= true;
if (e.allrules[p]) {
var j = e.allrules[p].alertText;
if (j) {
p = j
}
}
a._showPrompt(k, p, "", false, e, true)
}
}
}
e.onAjaxFormComplete(!l, g, n, e)
} else {
e.onAjaxFormComplete(true, g, n, e)
}
}
})
},
_validateField : function(c, j, o) {
if (!c.attr("id")) {
c.attr("id", "form-validation-field-"
+ b.validationEngine.fieldIdCounter);
++b.validationEngine.fieldIdCounter
}
if (c.is(":hidden") && !j.prettySelect || c.parent().is(":hidden")) {
return false
}
var q = c.attr(j.validateAttribute);
var v = /validate\[(.*)\]/.exec(q);
if (!v) {
return false
}
var r = v[1];
var n = r.split(/\[|,|\]/);
var k = false;
var h = c.attr("name");
var g = "";
var u = "";
var p = false;
j.isError = false;
j.showArrow = true;
var d = b(c.closest("form"));
for ( var t = 0; t < n.length; t++) {
n[t] = n[t].replace(" ", "");
var e = undefined;
switch (n[t]) {
case "required":
p = true;
e = a._getErrorMessage(d, c, n[t], n, t, j, a._required);
break;
case "custom":
e = a._getErrorMessage(d, c, n[t], n, t, j, a._custom);
break;
case "groupRequired":
var s = "[" + j.validateAttribute + "*=" + n[t + 1] + "]";
var f = d.find(s).eq(0);
if (f[0] != c[0]) {
a._validateField(f, j, o);
j.showArrow = true;
continue
}
e = a._getErrorMessage(d, c, n[t], n, t, j,
a._groupRequired);
if (e) {
p = true
}
j.showArrow = false;
break;
case "ajax":
e = a._ajax(c, n, t, j);
if (e) {
u = "load"
}
break;
case "minSize":
e = a._getErrorMessage(d, c, n[t], n, t, j, a._minSize);
break;
case "maxSize":
e = a._getErrorMessage(d, c, n[t], n, t, j, a._maxSize);
break;
case "min":
e = a._getErrorMessage(d, c, n[t], n, t, j, a._min);
break;
case "max":
e = a._getErrorMessage(d, c, n[t], n, t, j, a._max);
break;
case "past":
e = a._getErrorMessage(d, c, n[t], n, t, j, a._past);
break;
case "future":
e = a._getErrorMessage(d, c, n[t], n, t, j, a._future);
break;
case "dateRange":
var s = "[" + j.validateAttribute + "*=" + n[t + 1] + "]";
j.firstOfGroup = d.find(s).eq(0);
j.secondOfGroup = d.find(s).eq(1);
if (j.firstOfGroup[0].value || j.secondOfGroup[0].value) {
e = a._getErrorMessage(d, c, n[t], n, t, j,
a._dateRange)
}
if (e) {
p = true
}
j.showArrow = false;
break;
case "dateTimeRange":
var s = "[" + j.validateAttribute + "*=" + n[t + 1] + "]";
j.firstOfGroup = d.find(s).eq(0);
j.secondOfGroup = d.find(s).eq(1);
if (j.firstOfGroup[0].value || j.secondOfGroup[0].value) {
e = a._getErrorMessage(d, c, n[t], n, t, j,
a._dateTimeRange)
}
if (e) {
p = true
}
j.showArrow = false;
break;
case "maxCheckbox":
c = b(d.find("input[name='" + h + "']"));
e = a._getErrorMessage(d, c, n[t], n, t, j, a._maxCheckbox);
break;
case "minCheckbox":
c = b(d.find("input[name='" + h + "']"));
e = a._getErrorMessage(d, c, n[t], n, t, j, a._minCheckbox);
break;
case "equals":
e = a._getErrorMessage(d, c, n[t], n, t, j, a._equals);
break;
case "funcCall":
e = a._getErrorMessage(d, c, n[t], n, t, j, a._funcCall);
break;
case "creditCard":
e = a._getErrorMessage(d, c, n[t], n, t, j, a._creditCard);
break;
case "condRequired":
e = a
._getErrorMessage(d, c, n[t], n, t, j,
a._condRequired);
if (e !== undefined) {
p = true
}
break;
default:
}
if (e !== undefined) {
g += e + "
";
j.isError = true
}
}
if (!p && c.val().length < 1) {
j.isError = false
}
var l = c.prop("type");
if ((l == "radio" || l == "checkbox")
&& d.find("input[name='" + h + "']").size() > 1) {
c = b(d.find("input[name='" + h + "'][type!=hidden]:first"));
j.showArrow = false
}
if (c.is(":hidden") && j.prettySelect) {
c = d.find("#" + j.usePrefix + c.attr("id") + j.useSuffix)
}
if (j.isError) {
a._showPrompt(c, g, u, false, j)
} else {
if (!k) {
a._closePrompt(c)
}
}
if (!k) {
c.trigger("jqv.field.result", [ c, j.isError, g ])
}
var m = b.inArray(c[0], j.InvalidFields);
if (m == -1) {
if (j.isError) {
j.InvalidFields.push(c[0])
}
} else {
if (!j.isError) {
j.InvalidFields.splice(m, 1)
}
}
return j.isError
},
_getErrorMessage : function(c, n, l, p, g, q, m) {
var k = l;
if (l == "custom") {
var d = jQuery.inArray(l, p) + 1;
var o = p[d];
l = "custom[" + o + "]"
}
var e = (n.attr("data-validation-engine")) ? n
.attr("data-validation-engine") : n.attr("class");
var h = e.split(" ");
var j;
if (l == "future" || l == "past" || l == "maxCheckbox"
|| l == "minCheckbox") {
j = m(c, n, p, g, q)
} else {
j = m(n, p, g, q)
}
if (j != undefined) {
var f = a._getCustomErrorMessage(b(n), h, k, q);
if (f) {
return f
}
}
return j
},
_getCustomErrorMessage : function(j, e, h, l) {
var f = false;
var d = a._validityProp[h];
if (d != undefined) {
f = j.attr("data-errormessage-" + d);
if (f != undefined) {
return f
}
}
f = j.attr("data-errormessage");
if (f != undefined) {
return f
}
var c = "#" + j.attr("id");
if (typeof l.custom_error_messages[c] != "undefined"
&& typeof l.custom_error_messages[c][h] != "undefined") {
f = l.custom_error_messages[c][h]["message"]
} else {
if (e.length > 0) {
for ( var g = 0; g < e.length && e.length > 0; g++) {
var k = "." + e[g];
if (typeof l.custom_error_messages[k] != "undefined"
&& typeof l.custom_error_messages[k][h] != "undefined") {
f = l.custom_error_messages[k][h]["message"];
break
}
}
}
}
if (!f
&& typeof l.custom_error_messages[h] != "undefined"
&& typeof l.custom_error_messages[h]["message"] != "undefined") {
f = l.custom_error_messages[h]["message"]
}
return f
},
_validityProp : {
required : "value-missing",
custom : "custom-error",
groupRequired : "value-missing",
ajax : "custom-error",
minSize : "range-underflow",
maxSize : "range-overflow",
min : "range-underflow",
max : "range-overflow",
past : "type-mismatch",
future : "type-mismatch",
dateRange : "type-mismatch",
dateTimeRange : "type-mismatch",
maxCheckbox : "range-overflow",
minCheckbox : "range-underflow",
equals : "pattern-mismatch",
funcCall : "custom-error",
creditCard : "pattern-mismatch",
condRequired : "value-missing"
},
_required : function(g, h, e, d) {
switch (g.prop("type")) {
case "text":
case "password":
case "textarea":
case "file":
case "select-one":
case "select-multiple":
default:
if (!b.trim(g.val())
|| g.val() == g.attr("data-validation-placeholder")
|| g.val() == g.attr("placeholder")) {
return d.allrules[h[e]].alertText
}
break;
case "radio":
case "checkbox":
var f = g.closest("form");
var c = g.attr("name");
if (f.find("input[name='" + c + "']:checked").size() == 0) {
if (f.find("input[name='" + c + "']:visible").size() == 1) {
return d.allrules[h[e]].alertTextCheckboxe
} else {
return d.allrules[h[e]].alertTextCheckboxMultiple
}
}
break
}
},
_groupRequired : function(f, h, d, c) {
var g = "[" + c.validateAttribute + "*=" + h[d + 1] + "]";
var e = false;
f.closest("form").find(g).each(function() {
if (!a._required(b(this), h, d, c)) {
e = true;
return false
}
});
if (!e) {
return c.allrules[h[d]].alertText
}
},
_custom : function(j, k, d, l) {
var c = k[d + 1];
var g = l.allrules[c];
var h;
if (!g) {
alert("jqv:custom rule not found - " + c);
return
}
if (g.regex) {
var f = g.regex;
if (!f) {
alert("jqv:custom regex not found - " + c);
return
}
var e = new RegExp(f);
if (!e.test(j.val())) {
return l.allrules[c].alertText
}
} else {
if (g.func) {
h = g.func;
if (typeof (h) !== "function") {
alert("jqv:custom parameter 'function' is no function - "
+ c);
return
}
if (!h(j, k, d, l)) {
return l.allrules[c].alertText
}
} else {
alert("jqv:custom type not allowed " + c);
return
}
}
},
_funcCall : function(j, k, d, c) {
var h = k[d + 1];
var f;
if (h.indexOf(".") > -1) {
var g = h.split(".");
var e = window;
while (g.length) {
e = e[g.shift()]
}
f = e
} else {
f = window[h] || c.customFunctions[h]
}
if (typeof (f) == "function") {
return f(j, k, d, c)
}
},
_equals : function(f, g, e, d) {
var c = g[e + 1];
if (f.val() != b("#" + c).val()) {
return d.allrules.equals.alertText
}
},
_maxSize : function(h, j, f, e) {
var d = j[f + 1];
var c = h.val().length;
if (c > d) {
var g = e.allrules.maxSize;
return g.alertText + d + g.alertText2
}
},
_minSize : function(h, j, f, d) {
var e = j[f + 1];
var c = h.val().length;
if (c < e) {
var g = d.allrules.minSize;
return g.alertText + e + g.alertText2
}
},
_min : function(h, j, f, d) {
var e = parseFloat(j[f + 1]);
var c = parseFloat(h.val());
if (c < e) {
var g = d.allrules.min;
if (g.alertText2) {
return g.alertText + e + g.alertText2
}
return g.alertText + e
}
},
_max : function(h, j, f, e) {
var d = parseFloat(j[f + 1]);
var c = parseFloat(h.val());
if (c > d) {
var g = e.allrules.max;
if (g.alertText2) {
return g.alertText + d + g.alertText2
}
return g.alertText + d
}
},
_past : function(d, j, k, e, m) {
var c = k[e + 1];
var g = b(d.find("input[name='" + c.replace(/^#+/, "") + "']"));
var f;
if (c.toLowerCase() == "now") {
f = new Date()
} else {
if (undefined != g.val()) {
if (g.is(":disabled")) {
return
}
f = a._parseDate(g.val())
} else {
f = a._parseDate(c)
}
}
var l = a._parseDate(j.val());
if (l > f) {
var h = m.allrules.past;
if (h.alertText2) {
return h.alertText + a._dateToString(f) + h.alertText2
}
return h.alertText + a._dateToString(f)
}
},
_future : function(d, j, k, e, m) {
var c = k[e + 1];
var g = b(d.find("input[name='" + c.replace(/^#+/, "") + "']"));
var f;
if (c.toLowerCase() == "now") {
f = new Date()
} else {
if (undefined != g.val()) {
if (g.is(":disabled")) {
return
}
f = a._parseDate(g.val())
} else {
f = a._parseDate(c)
}
}
var l = a._parseDate(j.val());
if (l < f) {
var h = m.allrules.future;
if (h.alertText2) {
return h.alertText + a._dateToString(f) + h.alertText2
}
return h.alertText + a._dateToString(f)
}
},
_isDate : function(d) {
var c = new RegExp(
/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(?:(?:0?[1-9]|1[0-2])(\/|-)(?:0?[1-9]|1\d|2[0-8]))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(0?2(\/|-)29)(\/|-)(?:(?:0[48]00|[13579][26]00|[2468][048]00)|(?:\d\d)?(?:0[48]|[2468][048]|[13579][26]))$/);
return c.test(d)
},
_isDateTime : function(d) {
var c = new RegExp(
/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1}$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^((1[012]|0?[1-9]){1}\/(0?[1-9]|[12][0-9]|3[01]){1}\/\d{2,4}\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1})$/);
return c.test(d)
},
_dateCompare : function(d, c) {
return (new Date(d.toString()) < new Date(c.toString()))
},
_dateRange : function(e, f, d, c) {
if ((!c.firstOfGroup[0].value && c.secondOfGroup[0].value)
|| (c.firstOfGroup[0].value && !c.secondOfGroup[0].value)) {
return c.allrules[f[d]].alertText + c.allrules[f[d]].alertText2
}
if (!a._isDate(c.firstOfGroup[0].value)
|| !a._isDate(c.secondOfGroup[0].value)) {
return c.allrules[f[d]].alertText + c.allrules[f[d]].alertText2
}
if (!a._dateCompare(c.firstOfGroup[0].value,
c.secondOfGroup[0].value)) {
return c.allrules[f[d]].alertText + c.allrules[f[d]].alertText2
}
},
_dateTimeRange : function(e, f, d, c) {
if ((!c.firstOfGroup[0].value && c.secondOfGroup[0].value)
|| (c.firstOfGroup[0].value && !c.secondOfGroup[0].value)) {
return c.allrules[f[d]].alertText + c.allrules[f[d]].alertText2
}
if (!a._isDateTime(c.firstOfGroup[0].value)
|| !a._isDateTime(c.secondOfGroup[0].value)) {
return c.allrules[f[d]].alertText + c.allrules[f[d]].alertText2
}
if (!a._dateCompare(c.firstOfGroup[0].value,
c.secondOfGroup[0].value)) {
return c.allrules[f[d]].alertText + c.allrules[f[d]].alertText2
}
},
_maxCheckbox : function(h, j, k, g, f) {
var d = k[g + 1];
var e = j.attr("name");
var c = h.find("input[name='" + e + "']:checked").size();
if (c > d) {
f.showArrow = false;
if (f.allrules.maxCheckbox.alertText2) {
return f.allrules.maxCheckbox.alertText + " " + d + " "
+ f.allrules.maxCheckbox.alertText2
}
return f.allrules.maxCheckbox.alertText
}
},
_minCheckbox : function(h, j, k, g, f) {
var d = k[g + 1];
var e = j.attr("name");
var c = h.find("input[name='" + e + "']:checked").size();
if (c < d) {
f.showArrow = false;
return f.allrules.minCheckbox.alertText + " " + d + " "
+ f.allrules.minCheckbox.alertText2
}
},
_creditCard : function(k, l, f, n) {
var d = false, m = k.val().replace(/ +/g, "").replace(/-+/g, "");
var c = m.length;
if (c >= 14 && c <= 16 && parseInt(m) > 0) {
var g = 0, f = c - 1, j = 1, h, e = new String();
do {
h = parseInt(m.charAt(f));
e += (j++ % 2 == 0) ? h * 2 : h
} while (--f >= 0);
for (f = 0; f < e.length; f++) {
g += parseInt(e.charAt(f))
}
d = g % 10 == 0
}
if (!d) {
return n.allrules.creditCard.alertText
}
},
_ajax : function(o, r, j, s) {
var q = r[j + 1];
var n = s.allrules[q];
var e = n.extraData;
var l = n.extraDataDynamic;
var h = {
fieldId : o.attr("id"),
fieldValue : o.val()
};
if (typeof e === "object") {
b.extend(h, e)
} else {
if (typeof e === "string") {
var k = e.split("&");
for ( var j = 0; j < k.length; j++) {
var p = k[j].split("=");
if (p[0] && p[0]) {
h[p[0]] = p[1]
}
}
}
}
if (l) {
var g = [];
var m = String(l).split(",");
for ( var j = 0; j < m.length; j++) {
var c = m[j];
if (b(c).length) {
var d = o.closest("form").find(c).val();
var f = c.replace("#", "") + "=" + escape(d);
h[c.replace("#", "")] = d
}
}
}
if (s.eventTrigger == "field") {
delete (s.ajaxValidCache[o.attr("id")])
}
if (!s.isError && !a._checkAjaxFieldStatus(o.attr("id"), s)) {
b.ajax({
type : s.ajaxFormValidationMethod,
url : n.url,
cache : false,
dataType : "json",
data : h,
field : o,
rule : n,
methods : a,
options : s,
beforeSend : function() {
},
error : function(i, t) {
a._ajaxError(i, t)
},
success : function(v) {
var x = v[0];
var u = b(b("input[id='" + x + "']")[0]);
if (u.length == 1) {
var t = v[1];
var w = v[2];
if (!t) {
s.ajaxValidCache[x] = false;
s.isError = true;
if (w) {
if (s.allrules[w]) {
var i = s.allrules[w].alertText;
if (i) {
w = i
}
}
} else {
w = n.alertText
}
a._showPrompt(u, w, "", true, s)
} else {
s.ajaxValidCache[x] = true;
if (w) {
if (s.allrules[w]) {
var i = s.allrules[w].alertTextOk;
if (i) {
w = i
}
}
} else {
w = n.alertTextOk
}
if (w) {
a._showPrompt(u, w, "pass", true, s)
} else {
a._closePrompt(u)
}
if (s.eventTrigger == "submit") {
o.closest("form").submit()
}
}
}
u.trigger("jqv.field.result", [ u, s.isError, w ])
}
});
return n.alertTextLoad
}
},
_ajaxError : function(c, d) {
if (c.status == 0 && d == null) {
alert("The page is not served from a server! ajax call failed")
} else {
if (typeof console != "undefined") {
console.log("Ajax error: " + c.status + " " + d)
}
}
},
_dateToString : function(c) {
return c.getFullYear() + "-" + (c.getMonth() + 1) + "-"
+ c.getDate()
},
_parseDate : function(e) {
var c = e.split("-");
if (c == e) {
c = e.split("/")
}
return new Date(c[0], (c[1] - 1), c[2])
},
_showPrompt : function(i, g, h, f, e, d) {
var c = a._getPrompt(i);
if (d) {
c = false
}
if (c) {
a._updatePrompt(i, c, g, h, f, e)
} else {
a._buildPrompt(i, g, h, f, e)
}
},
_buildPrompt : function(h, c, f, j, k) {
var d = b("