1.Use custom pattern format to a registration form text field and make it required field (exp. name or username).
2.Create a 'select' custom field and make it to be required field.
3.Try to register by input first field by use correct format and leave second field(select field) to un-selected(dont select anything for second field).
Joomla validate form properly.
Found javascript error message 'l is not a function'.
windows 10
google chrome web browser.
joomla versions 3.8.8.
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 and then it works properly.
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)
}
Status | New | ⇒ | Information Required |
No have this fix in latest release 3.8.10.
Can you please enable debug mode and check again, because this is a minified version.
Status | Information Required | ⇒ | Discussion |
I tested on debug mode already, not found htis problem. This provlem occurs on minified version only.
I think cause of equivalent validate() function on debug mode has enough variables at the first line:
validate = function(el) {
var $el = jQuery(el), tagName, handler; //<---------- I think this line is not same with compressed version of validate.js.
// Ignore the element if its currently disabled, because are not submitted for the http-request. For those case return always true.
if ($el.attr('disabled')) {
handleResponse(true, $el);
return true;
}
// If the field is required make sure it has a value
if ($el.attr('required') || $el.hasClass('required')) {
tagName = $el.prop("tagName").toLowerCase();
if (tagName === 'fieldset' && ($el.hasClass('radio') || $el.hasClass('checkboxes'))) {
if (!$el.find('input:checked').length){
handleResponse(false, $el);
return false;
}
//If element has class placeholder that means it is empty.
} else if (!$el.val() || $el.hasClass('placeholder') || ($el.attr('type') === 'checkbox' && !$el.is(':checked'))) {
handleResponse(false, $el);
return false;
}
}
// Only validate the field if the validate class is set
handler = ($el.attr('class') && $el.attr('class').match(/validate-([a-zA-Z0-9\_\-]+)/)) ? $el.attr('class').match(/validate-([a-zA-Z0-9\_\-]+)/)[1] : "";
// Try HTML5 pattern first then the handlers
if ($el.attr('pattern') && $el.attr('pattern') != '') {
if ($el.val().length) {
isValid = new RegExp('^'+$el.attr('pattern')+'$').test($el.val());
handleResponse(isValid, $el);
return isValid;
}
if ($el.attr('required') || $el.hasClass('required')) {
handleResponse(false, $el);
return false;
}
handleResponse(true, $el);
return true;
} else {
if (handler === '') {
handleResponse(true, $el);
return true;
}
// Check the additional validation types
if ((handler) && (handler !== 'none') && (handlers[handler]) && $el.val()) {
// Execute the validation handler and return result
if (handlers[handler].exec($el.val(), $el) !== true) {
handleResponse(false, $el);
return false;
}
}
// Return validation state
handleResponse(true, $el);
return true;
}
},
Can you try to minify the uncompressed file via an online tool like https://jscompress.com/ and then exchange the file to test?
Labels |
Added:
J3 Issue
|
Status | Discussion | ⇒ | Information Required |
@iamkeng is this occurring still and if so have you tried the recommendations?
Status | Information Required | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-05-08 16:21:31 |
Closed_By | ⇒ | SharkyKZ |
Closed_Date | 2020-05-08 16:21:31 | ⇒ | 2020-05-08 16:21:32 |
Closed_By | SharkyKZ | ⇒ | joomla-cms-bot |
Set to "closed" on behalf of @SharkyKZ by The JTracker Application at issues.joomla.org/joomla-cms/20789
Please test PR #28996.
Can a Developer please have a Look at this Issue and Answer?
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20789.