From 4360ad6502630b80c66b4ec380d6149369a7c132 Mon Sep 17 00:00:00 2001 From: Stephen Abello Date: Wed, 24 Jul 2024 12:01:19 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B07698=20-=20Fix=20plain=20text=20value=20?= =?UTF-8?q?in=20HTML=20field=20being=20seen=20empty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/forms-json-utils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/forms-json-utils.js b/js/forms-json-utils.js index c7f04cb8d..e4e58ed5f 100644 --- a/js/forms-json-utils.js +++ b/js/forms-json-utils.js @@ -324,11 +324,11 @@ function ValidateCKEditField(sFieldId, sPattern, bMandatory, sFormId, nullValue, return; } let sTextContent; - // Get the contents without the tags let sFormattedContent = oCKEditor.getData(); - // Get the contents without the tags - sTextContent = $(sFormattedContent).text(); + // Get the contents without the tags + // Check if we have a formatted content that is HTML, otherwise we just have plain text, and we can use it directly + sTextContent = $(sFormattedContent).length > 0 ? $(sFormattedContent).text() : sFormattedContent; if (sTextContent === '') { // No plain text, maybe there is just an image