Expand my Community achievements bar.

SOLVED

Set character limit on personalisation block

Avatar

Level 2

Hello, 
I'm wondering if there's a way to set a character limit on copy coming through from a personalised piece of content so it can be truncated 

For instance
<%= targetData.Description %> will return: 
Lorem ipsum dolor sit amet, consectetur adipiscing elit

 

Where the ideal will be for it to return:
Lorem ipsum dolor sit amet ...

Any help would be appreciated

1 Accepted Solution

Avatar

Correct answer by
Level 2

You can use textarea max length (maxlength="50") this is in the HTML property best of HTML

 

You can add is CSS and can be utilized in all over HTML

View solution in original post

5 Replies

Avatar

Level 2

@AndyHu1  where exactly you want to use it.  If this is to display in email, there is other way around to achive it.

Avatar

Level 2

Hi @ashish1212 , thanks for the reply

Yes this being used in an email, image example attached

Ideally I want to to do this in a the script as it may be needed elsewhere with a different character limit

Screenshot 2024-09-18 at 09.43.59.png

Avatar

Correct answer by
Level 2

You can use textarea max length (maxlength="50") this is in the HTML property best of HTML

 

You can add is CSS and can be utilized in all over HTML

Avatar

Level 2

Thanks, that's probably the way I'll go for now. I'd like to have have various option on what comes after the truncated copy (ie [...] or see more link

Avatar

Community Advisor

Hi @AndyHu1 ,

If you need to truncate after a specific number of character you can use slice.

If you need to truncate after a specific word then you need a combination of index and slice.

 

Thanks,

David



David Kangni