# Reg: text area

**URL:** <https://www.ruby-forum.com/t/reg-text-area/89413>\
**Category:** Rails\
**Created:** [March 20, 2007, 10:38am UTC](https://www.ruby-forum.com/t/reg-text-area/89413 "2007-03-20T10:38:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shiva\_98](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@shiva\_98](https://www.ruby-forum.com/u/shiva_98)\
**Post date:** [March 20, 2007, 10:38am UTC](https://www.ruby-forum.com/t/reg-text-area/89413/1 "2007-03-20T10:38:41Z")

</div>

how to limit the text area? for eg: if text area consists of only 160  
characters,user should not exceeds the limit while typing itself

---

<div class="post-metadata">

**Author:** ![shiva\_98](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@shiva\_98](https://www.ruby-forum.com/u/shiva_98)\
**Post date:** [March 20, 2007, 12:13pm UTC](https://www.ruby-forum.com/t/reg-text-area/89413/2 "2007-03-20T12:13:06Z")

</div>

Shiva S. wrote:

> how to limit the text area? for eg: if text area consists of only 160  
> characters,user should not exceeds the limit while typing itself

Using Javascript  
[http://www.google.com/search?q=how+to+limit+textarea+size](http://www.google.com/search?q=how+to+limit+textarea+size) on the  
client side, validation on the Rails size.

–  
Jakob S. - [http://mentalized.net](http://mentalized.net)

---

<div class="post-metadata">

**Author:** ![shiva\_98](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@shiva\_98](https://www.ruby-forum.com/u/shiva_98)\
**Post date:** [March 20, 2007, 2:36pm UTC](https://www.ruby-forum.com/t/reg-text-area/89413/3 "2007-03-20T14:36:04Z")

</div>

Shiva S. wrote:

> how to limit the text area? for eg: if text area consists of only 160  
> characters,user should not exceeds the limit while typing itself

You can either do it by using Javascript, so the user cannot put more  
text then 160 char in the textfield, or you can use Rails to cut the  
first 160 char and erase the last.

Javascript

> **[How to Limit the Number of Characters in a Textarea or Text Field](https://www.mediacollege.com/internet/javascript/form/limit-characters.html)**
>
> How to limit the number of characters in a text field or textarea using JavaScript. Includes a display of how many characters left.
