Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Limiting TexareaField Characters input


Reply

3 Posts   1350 Views

Avatar
ciaranhickey

4 August 2010 at 11:59pm Community Member, 17 Posts

Hi,

I'm trying to limit the amount of characters that can be entered into a TextareaField in the admin area (eg. 400 char limit) but I can't seem to find any info on this on the forum or documentation.

I can limit a simple TextField using

$f->addFieldToTab("Root.Content.Main", new TextField('Intro', 'Intro', '', 400), 'Content');

But can't find anything for TextareaField.

Any help would be appreciated.

Regards,
Ciarán

Avatar
Willr

5 August 2010 at 7:59pm Forum Moderator, 5511 Posts

No way AFAIK built in to do this. Whenever I've had to do this I've implemented a custom jQuery based solution like http://www.devcurry.com/2009/08/limit-number-of-characters-in-textarea.html

Avatar
ciaranhickey

6 August 2010 at 12:13am Community Member, 17 Posts

Thanks for your help Willr.

I'll give the jQuery solution a go!

Regards,
Ciarán