Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

required and maxlength properties in rich text field

Avatar

Level 2

I' making a component that required a rich text field in the dialog. It is working, but the properties maxlength and required do nothing for this field. I have them configured properly but I can add any number of characters and save the dialog with no text in my rich textfield. I did the component taking as a base the richtextfield in /libs/foundation/components/text component because it has a rich text inside the dialog similar to the one I need.

I've attached an image with my configuration,

I need to make the maxlegth and required properties work

1 Accepted Solution

Avatar

Correct answer by
Level 9

The RTE does not support max length and required properties.

Alternatively you can use allowBlank= false for required and for maxlength you can add a listener (validator) on click of OK button of dialog checking the length of the characters entered in RTE and validate accordingly.

View solution in original post

6 Replies

Avatar

Level 2

I need rich text editing capabilities, so using textarea does not solve my problem

Avatar

Level 10

The RTE in Touch UI is not a granite Data type like TextArea i listed above and does not ahve the same properties. Its a script located here: 

/libs/cq/gui/components/authoring/dialog/componentstyles/componentstyles.jsp

To get this functionality - you would need to overlay the script and modify the application logic to support a max length. 

Avatar

Correct answer by
Level 9

The RTE does not support max length and required properties.

Alternatively you can use allowBlank= false for required and for maxlength you can add a listener (validator) on click of OK button of dialog checking the length of the characters entered in RTE and validate accordingly.

allowBlank= false for required how can we add this can yo please help with the screenshot

Avatar

Level 4

Add a property "validateValue" in your rte field and add this function as the value, This is working for me. Change the length in if condition according to your need.

function(field){
var temp=this.getValue();
                                if(temp.length>500){
                                                this.markInvalid("Description should not exceed 500 characters");
                                                return false;
                                }else{
                                                this.clearInvalid();
                                                return true;
                                }
}