J3 Issue ?
Referenced as Pull Request for: # 28996
avatar iamkeng
iamkeng
18 Jun 2018

Steps to reproduce the issue

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).

Expected result

Joomla validate form properly.

Actual result

Found javascript error message 'l is not a function'.

System information (as much as possible)

windows 10
google chrome web browser.
joomla versions 3.8.8.

Additional comments

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)
}

avatar iamkeng iamkeng - open - 18 Jun 2018
avatar joomla-cms-bot joomla-cms-bot - labeled - 18 Jun 2018
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 25 Jun 2018

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.

avatar franz-wohlkoenig franz-wohlkoenig - change - 25 Jun 2018
Status New Information Required
avatar iamkeng
iamkeng - comment - 27 Jun 2018

No have this fix in latest release 3.8.10.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20789.

avatar iamkeng iamkeng - change - 27 Jun 2018
The description was changed
avatar iamkeng iamkeng - edited - 27 Jun 2018
avatar iamkeng iamkeng - change - 27 Jun 2018
The description was changed
avatar iamkeng iamkeng - edited - 27 Jun 2018
avatar HLeithner
HLeithner - comment - 27 Jun 2018

Can you please enable debug mode and check again, because this is a minified version.

avatar franz-wohlkoenig franz-wohlkoenig - change - 27 Jun 2018
Status Information Required Discussion
avatar iamkeng
iamkeng - comment - 10 Jul 2018

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;
	    }
 	},

This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20789.
avatar infograf768
infograf768 - comment - 10 Jul 2018

Can you try to minify the uncompressed file via an online tool like https://jscompress.com/ and then exchange the file to test?

avatar brianteeman brianteeman - change - 2 Aug 2018
Labels Added: J3 Issue
avatar brianteeman brianteeman - labeled - 2 Aug 2018
avatar jwaisner jwaisner - change - 18 Mar 2020
Status Discussion Information Required
avatar jwaisner
jwaisner - comment - 18 Mar 2020

@iamkeng is this occurring still and if so have you tried the recommendations?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20789.

avatar joomla-cms-bot joomla-cms-bot - close - 8 May 2020
avatar SharkyKZ SharkyKZ - change - 8 May 2020
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2020-05-08 16:21:31
Closed_By SharkyKZ
avatar joomla-cms-bot joomla-cms-bot - change - 8 May 2020
Closed_Date 2020-05-08 16:21:31 2020-05-08 16:21:32
Closed_By SharkyKZ joomla-cms-bot
avatar joomla-cms-bot
joomla-cms-bot - comment - 8 May 2020

Set to "closed" on behalf of @SharkyKZ by The JTracker Application at issues.joomla.org/joomla-cms/20789

avatar SharkyKZ
SharkyKZ - comment - 8 May 2020

Please test PR #28996.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20789.

Add a Comment

Login with GitHub to post a comment