SEBLOD icon indicating copy to clipboard operation
SEBLOD copied to clipboard

COM_CCK_PLEASE_CHECK_REQUIRED_TABS core text constant causes JavaScript error on client side, that prevents the form validation. SEBLOD 3.22.1 and Joomla 3.10.11

Open TrackerBlaster opened this issue 2 years ago • 1 comments

Hi dear developers,

The COM_CCK_PLEASE_CHECK_REQUIRED_TABS text constant causes a JavaScript error on the client side, that prevents the form validations on Seblod form pages.

The problem is the following:

COM_CCK_PLEASE_CHECK_REQUIRED_TABS="<small>Please check <span class="red">red</span> tab(s).</small>"

In the constant text, the "red" causes the JavaScript error on the client side, because the " (quotation mark) brakes the JavaScript element list on the client side, so the other JavaScript code cannot run. This is the part of the JQuery's new tab validation functions.

Example from a page, where I created a SEBLOD form with required fields, but without tabs. For the easy reading, I formatted the code, that SEBLOD generated. (look the _tabs element, that is broken):

jQuery(document).ready(function($) {
	$.validationEngineLanguage.newLang({
		"required": {
			"regex": "none",
			"alertText": "* This field is required.",
			"alertTextCheckboxe": "* This field must be checked.",
			"alertTextCheckboxMultiple": "* You have to choose an option."
		},
		"email": {
			"regex": /^([A-Za-z0-9_\-\.'])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,10})$/,
			"alertText": "* The email address is invalid"
		},
		"maxSize": {
			"regex": "none",
			"alertText": "* Maximum ",
			"alertText2": " chars allowed"
		},
		"_tabs": {
			"regex": "",
			"alertText": "<small>Please check <span class="
			red ">red</span> tab(s).</small>"
		}
	});
	$("#seblod_form").validationEngine({
		scroll: true,
		promptPosition: "inline"
	});
});

The error message in Firefox:

SyntaxError: missing } after property list

I could solve this situation with a language override like this:

COM_CCK_PLEASE_CHECK_REQUIRED_TABS="<small>Please check <b>red</b> tab(s).</small>"

Other text constants will be problematic too, because of the above error, if quotation marks are used in the text constants, regardless of the used language in the text constants.

So, this is a core problem of Seblod, so this need to be solved in the core.

Greetings,

TrackerBlaster avatar Sep 13 '22 12:09 TrackerBlaster

Maybe, store the string in the database like this, would be a good solution:

COM_CCK_PLEASE_CHECK_REQUIRED_TABS=\"<small>Please check <span class=\\\"red\\\">red</span> tab(s).</small>\"

TrackerBlaster avatar Sep 14 '22 13:09 TrackerBlaster

Hi @TrackerBlaster,

Thank you. This is fixed within SEBLOD 3.28.0 and 4.2.0

Sebastien

sebastienheraud avatar Jan 26 '24 16:01 sebastienheraud