Sachin R
Sachin R

Reputation: 11876

Text Area helper , how to set maxlength

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

Upvotes: 2

Views: 1066

Answers (2)

Srinivas M.V.
Srinivas M.V.

Reputation: 6608

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 !

Upvotes: 6

Andrea Pavoni
Andrea Pavoni

Reputation: 5311

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.

Upvotes: 2

Related Questions