Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Validation on Multi Line Text Field in Content Fragment

Avatar

Level 2

I'm using AEM as a Cloud Service. In that I have created a content fragment model. The model has a Multi Line Text Field which I'm using as Text Area and the default type is set to RTE. Please see the image below:screenshot-dev.krisshop.com_4502-2024.06.07-14_44_24.png

 

For this field, I want to set the maximum character length but ootb it is not present. I have checked many URLs but did not find any feasible solution. Is there any way we can implement the max character limit in Multi Line Text field?

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

2 Replies

Avatar

Community Advisor

HI @NikitaTailor24 ,

Yes, you can implement a maximum character limit validation on a Multi Line Text Field in a Content Fragment Model (CFM) in AEM as a Cloud Service. Here are the steps to do so:

1. Open the CFM model in your AEM instance.
2. Navigate to the "Elements" tab in the CFM editor.
3. Find the "Multi Line Text" element and click on it to edit its properties.
4. In the "Validation" section, click on the "Add" button to add a new validation rule.
5. In the "Validation Rule" dialog, set the following properties:
- Rule Type: "Custom"
- Name: "Max Length"
- Description: "Maximum character length validation"
- Function: "function (value) { return value.length <= 100; }" (replace "100" with your desired maximum character length)
6. Click on the "Save" button to save the validation rule.
7. Save the changes to the CFM model.

After following these steps, the Multi Line Text Field in your CFM model will have a maximum character length validation of 100 characters (or your desired length). When a user tries to enter more than the allowed number of characters, they will see an error message indicating that the input is too long.

Avatar

Level 2

Hi , 

I tried above one but couldn't find validation section can provide screenshot where validation section is present in cf model.

Thanks.