views:

42

answers:

2

Text Area helper , how i set the maximum length of string to 100.
Is there is any max length attribute in text-area helper in ROR.

Code will help me.Thanks

+2  A: 

in textarea there aren't lengths, you can set columns and rows, so you can have a textarea widht of '100 columns' but it doesn't mean that it will accept only 100 chars.

apeacox
+4  A: 

By default at the View level rails doesn't provide the character limit for text area . You can explictly use Javascript function which limits the Number of the Characters entered with onKeyUp and onKeyDown events in your view and place the function in public/javascript/application.js .

Here is a nice tutorial for character limit within text area .

Hope it is useful !

YetAnotherCoder
The W3C HTML spec doesn't provide a property to limit a `textarea` to a maximum number of characters either. You need to use javascript to achieve this, regardless of your framework.
nfm