Developer forum

Forum » Templates » Define amount of letters in text

Define amount of letters in text

Martin Kure
Reply

Hi and sorry for spamming you with questions, 

while working with items and newsletter templates I have a question:

Is there a tag to determing how many letters you wanna display from them the item/list.

Example:

I'm using an item for people to add content to a newsletter - creating headlines text, images etc. However, the design of the newsletter will be ruined and pushed around, if somebody pasted 5-600 words in an item used for the headline. Therefor, it would be great, if I in some way could define and controle the amount of letters allowed in that item, either by controlling how many letters will be displayed in the document or by giving the item a max value.

Regards

Martin


Replies

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

Hi Martin

In your template, you can do 2 things:

You can also limit the allowed amount of characters to type in the admin using the validation field on the item field definition and use a regular expression that limits the amount of characters, i.e. like:

/^[a-zA-Z0-9]{0,10}$/

See http://manual.dynamicweb-cms.com/Dynamicweb-On-line-Manual/Items/Item-fields.aspx

Hope this helps.

Nicolai

Votes for this answer: 1
 
Sten Hougaard
Reply

Hi Nicolai,

I have the same issue - I need no more than 155 chars and have tried to add the regex below to the textfield in an item. Every time I try to save it I get an error (as if there were more than 155 chars, which there is not). Am I missing something?

^[\d\D]{0,155}$


Med venlig hilsen/Best regards,

Sten Hougaard
Webudvikler

E: sho@1stweb.dk
M: 29850818
A: København/Aarhus . W: www.1stweb.dk
@: netsi1964

 
Mikkel Ricky
Reply
This post has been marked as an answer

Hi Sten,

You've found a bug (#15760). The regular expression used for validation in JavaScript is not escaped correctly.

More specifically, the backslashes are not escaped meaning that the expression ^[\d\D]{0,155}$ will only match strings consisting solely of the characters d and D … 

Thanks for helping us find this bug.

Best regards,
Mikkel

Votes for this answer: 1
 
Kristian Kirkholt
Reply

Hi Sten

The problem regarding #15760 "Item field regular expression used for validation in JavaScript is not escaped correctly" has now been resolved in Hotfix version 8.4.1.19 and will be available on version 8.5.0.2 shortly

You are able to find the 8.4.1.19 version in the Developer download section.

http://developer.dynamicweb-cms.com/downloads/dynamicweb-8.aspx

Please contact Dynamicweb Support if you need any additional help regarding this.

Kind Regards

Dynamicweb Support
Kristian Kirkholt

 

 

You must be logged in to post in the forum