-
Notifications
You must be signed in to change notification settings - Fork 1
/
abValidate.min.js
1 lines (1 loc) · 2.86 KB
/
abValidate.min.js
1
!function (e) { e.fn.abValidate = function (o) { var l = e.extend({ color: "#556b2f", backgroundColor: "white", debug: !1 }, o), a = this, s = !1, r = !1; function n(o) { var a = !0; try { o.find(".ab-validation-i").each(function () { var o, s = e(this).attr("ab-validation").replace(/,\s*$/, "").split(","), r = e(this).next(), n = e(this).parent(), i = !1; r.html(""); for (var t = 0; t < s.length; t++) { (d = (c = s[t].trim().split(":"))[0]).indexOf("required") >= 0 && (i = !0) } l.debug && console.log(s); for (t = 0; t < s.length; t++) { var c, d = (c = s[t].trim().split("|"))[0].split(":")[0], u = c[0].split(":")[1] ? c[0].split(":")[1] : null, g = c[1], b = !1, p = !i && e(this).val().length <= 0; switch (l.debug && (console.log("------------"), console.log("valName: " + d), console.log("valMsg: " + g), console.log("valValue: " + u), console.log("valErrors: " + b), console.log("isNotReq: " + p), console.log("------------")), d) { case "required": e(this).val().length <= 0 && (b = !0, l.debug && console.log("Required"), null == g && (g = "Required"), n.addClass("netm-form-group-error"), r.css("display", "block"), r.append("* " + g + "<br>")); break; case "min": if (p) break; var f = parseInt(u), m = g; e(this).val().length < f && (l.debug && console.log("Min"), b = !0, null == m && (m = "Min"), n.addClass("netm-form-group-error"), r.css("display", "block"), r.append("* " + m + "<br>")); break; case "max": if (p) break; f = parseInt(u), m = g; e(this).val().length > f && (l.debug && console.log("Max"), b = !0, null == m && (m = "Max"), n.addClass("netm-form-group-error"), r.css("display", "block"), r.append("* " + m + "<br>")); break; case "confirm": if (p) break; var h = e("#" + u), v = g; e(this).val() != h.val() && (l.debug && console.log("Confirm"), b = !0, null == v && (v = "Confirm"), n.addClass("netm-form-group-error"), r.css("display", "block"), r.append("* " + v + "<br>")); break; case "email": if (p) break; o = e(this).val(), void 0, /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/, /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(o).toLowerCase()) || (l.debug && console.log("Email"), b = !0, null == g && (g = "Email"), n.addClass("netm-form-group-error"), r.css("display", "block"), r.append("* " + g + "<br>")); break; default: if (p) break; l.debug && console.log("Default"), b = !0 }b ? a = !1 : (n.removeClass("netm-form-group-error"), r.css("display", "none")) } }) } catch (e) { console.log(e) } return r = a, a } return this.submit(function (e) { return s = !0, n(a) }), this.find(".ab-validation-i").each(function () { e(this).keyup(function () { s && n(a) }), e(this).prop("autocomplete", "off") }), { success: r, message: "Message ya !" } } }(jQuery);