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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Limiting TexareaField Characters input


Go to End


3 Posts   2508 Views

Avatar
ciaranhickey

Community Member, 17 Posts

4 August 2010 at 11:59pm

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

Forum Moderator, 5523 Posts

5 August 2010 at 7:59pm

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

Community Member, 17 Posts

6 August 2010 at 12:13am

Thanks for your help Willr.

I'll give the jQuery solution a go!

Regards,
Ciarán