Page 1 of 1

I found some bug about form's field validation of custom pattern format.

Posted: Mon Jun 18, 2018 11:28 am
by iamkeng
Hi,
I found some bug in media/system/js/validate.js about form's field validation of custom pattern format. JS canot validate the form with custom pattern format because found javascript error occurs with error message "l is not a function".

Because of in context of funtion i() use global variable 'l' in this statement:

Code: Select all

(l = new RegExp("^" + r.attr("pattern") + "$").test(r.val()), n(l, r), l)
So I added variable 'l' initializing to at the first line of the context of this function to make it to be local variable like as I leave message in the comment below. After that it works properly.

Code: Select all

i = function(e) {
            var a, l, r = jQuery(e);// <--- I added variable 'l' to this line after that it worksproperly.
            if (r.attr("disabled")) return n(!0, r), !0;
            if (r.attr("required") || r.hasClass("required"))
                if ("fieldset" === r.prop("tagName").toLowerCase() && (r.hasClass("radio") || r.hasClass("checkboxes"))) {
                    if (!r.find("input:checked").length) return n(!1, r), !1
                } else if (!r.val() || r.hasClass("placeholder") || "checkbox" === r.attr("type") && !r.is(":checked")) return n(!1, r), !1;
            return a = r.attr("class") && r.attr("class").match(/validate-([a-zA-Z0-9\_\-]+)/) ? r.attr("class").match(/validate-([a-zA-Z0-9\_\-]+)/)[1] : "", r.attr("pattern") && "" != r.attr("pattern") ? r.val().length ? (l = new RegExp("^" + r.attr("pattern") + "$").test(r.val()), n(l, r), l) : r.attr("required") || r.hasClass("required") ? (n(!1, r), !1) : (n(!0, r), !0) : "" === a ? (n(!0, r), !0) : a && "none" !== a && t[a] && r.val() && !0 !== t[a].exec(r.val(), r) ? (n(!1, r), !1) : (n(!0, r), !0)
        }

Re: I found some bug about form's field validation of custom pattern format.

Posted: Mon Jun 18, 2018 9:02 pm
by mandville