Rich text editor no 'required' option

Hello @peter.b,

In Retool, the Rich Text Editor doesn’t have a built-in "required" option like other form fields. To add validation, use custom logic for example, check if the content is empty before submitting the form (like mention in this community forum : Rich text editor missing basic functionality - #3 by Jack_T).

Use a transformer or a JavaScript query to validate:

// Custom validation query
const plainText = richTextEditor1.value.replace(/<[^>]*>?/gm, '').trim();

if (!plainText) {
  utils.showNotification({ title: "Error", description: "Rich text is required.", type: "error" });
  return false;
}

return true;

  1. Add a Text Component to Show an Error Message :
  • Find the "Hidden" toggle in the right-hand panel.
  • Paste this code:
    {{ !!richTextEditor1.value.replace(/<[^>]*>?/gm, '').trim() }}
  1. Execute the JavaScript query within the Rich Text Editor’s event handlers.

  2. Here is a sample screen recording for reference.

2 Likes